CI: make versionCode step POSIX sh compatible
The runner executes workflow steps with /bin/sh (dash), which has no here-strings: `IFS='.' read -r MAJ MIN PAT <<< "$VERSION"` failed with "Syntax error: redirection unexpected" and aborted the Android release build. Parse the semver with `cut` instead, drop the GNU-only `\s` from the sed expression in favour of [[:space:]], and default any missing component to 0 so a malformed version can never emit versionCode 0. Verified under sh: 0.0.14 -> 1014, 0.0.15 -> 1015, 0.1.0 -> 1100, 1.0.0 -> 11000 (monotonic). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user