diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index da16be36..eda62564 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -184,10 +184,15 @@ jobs: # Derive an explicit code that is both monotonic in semver order and # always above the 1000 floor already in the field: # code = 1000 + major*10000 + minor*100 + patch - # e.g. 0.0.15 -> 1015, 0.1.0 -> 11000, 1.0.0 -> 1010000. + # e.g. 0.0.14 -> 1014, 0.0.15 -> 1015, 0.1.0 -> 1100, 1.0.0 -> 11000. + # POSIX sh only (the runner uses dash): no here-strings, no \s in sed. PROPS="src-tauri/gen/android/app/tauri.properties" - VERSION=$(grep '"version"' src-tauri/tauri.conf.json | sed -E 's/.*"version"\s*:\s*"([^"]+)".*/\1/') - IFS='.' read -r MAJ MIN PAT <<< "$VERSION" + VERSION=$(grep '"version"' src-tauri/tauri.conf.json | head -1 | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/') + MAJ=$(echo "$VERSION" | cut -d. -f1) + MIN=$(echo "$VERSION" | cut -d. -f2) + PAT=$(echo "$VERSION" | cut -d. -f3) + # Guard against a malformed/missing component so we never emit code 0. + : "${MAJ:=0}" "${MIN:=0}" "${PAT:=0}" CODE=$(( 1000 + MAJ*10000 + MIN*100 + PAT )) echo "version=$VERSION -> versionCode=$CODE" if grep -q '^tauri.android.versionCode=' "$PROPS"; then