fix(android): stamp versionCode and versionName from the release tag
AndroidManifest.xml had hardcoded versionCode=1 / versionName=1.0, so every shipped APK looked identical to Android and Obtainium could never confirm the installed version matched the latest release tag — causing a persistent false-update notification loop. VERSION_NAME is now passed into the build script from the CI tag (e.g. "v0.28.0" → versionCode=2800, versionName="0.28.0") and forwarded to aapt2 link via --version-code / --version-name, overriding the manifest without touching the file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,7 @@ jobs:
|
|||||||
KEYSTORE_PASS: ${{ secrets.RELEASE_KEYSTORE_PASS }}
|
KEYSTORE_PASS: ${{ secrets.RELEASE_KEYSTORE_PASS }}
|
||||||
KEY_ALIAS: release
|
KEY_ALIAS: release
|
||||||
KEY_PASS: ${{ secrets.RELEASE_KEYSTORE_PASS }}
|
KEY_PASS: ${{ secrets.RELEASE_KEYSTORE_PASS }}
|
||||||
|
VERSION_NAME: ${{ steps.tag.outputs.name }}
|
||||||
run: bash scripts/build_android_apk.sh
|
run: bash scripts/build_android_apk.sh
|
||||||
|
|
||||||
- name: Get tag name
|
- name: Get tag name
|
||||||
|
|||||||
@@ -75,12 +75,23 @@ if [ -d "$RES_DIR" ]; then
|
|||||||
"$BT/aapt2" compile --dir "$RES_DIR" -o "$STAGING/compiled-res"
|
"$BT/aapt2" compile --dir "$RES_DIR" -o "$STAGING/compiled-res"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Derive versionCode/versionName from VERSION_NAME env var (e.g. "v0.28.0" → code 2800, name "0.28.0").
|
||||||
|
# Falls back to the values hardcoded in AndroidManifest.xml when not set (local debug builds).
|
||||||
|
VERSION_CODE=""
|
||||||
|
if [ -n "${VERSION_NAME:-}" ]; then
|
||||||
|
VN="${VERSION_NAME#v}"
|
||||||
|
IFS='.' read -r _MAJ _MIN _PAT <<< "$VN"
|
||||||
|
VERSION_CODE=$(( ${_MAJ:-0} * 10000 + ${_MIN:-0} * 100 + ${_PAT:-0} ))
|
||||||
|
fi
|
||||||
|
|
||||||
LINK_ARGS=(
|
LINK_ARGS=(
|
||||||
link
|
link
|
||||||
-o "$STAGING/app-unsigned.apk"
|
-o "$STAGING/app-unsigned.apk"
|
||||||
-I "$PLATFORM_JAR"
|
-I "$PLATFORM_JAR"
|
||||||
--manifest "$MANIFEST"
|
--manifest "$MANIFEST"
|
||||||
)
|
)
|
||||||
|
[ -n "$VERSION_CODE" ] && LINK_ARGS+=( --version-code "$VERSION_CODE" )
|
||||||
|
[ -n "${VERSION_NAME:-}" ] && LINK_ARGS+=( --version-name "${VERSION_NAME#v}" )
|
||||||
[ -d "$ASSETS_DIR" ] && LINK_ARGS+=( -A "$ASSETS_DIR" )
|
[ -d "$ASSETS_DIR" ] && LINK_ARGS+=( -A "$ASSETS_DIR" )
|
||||||
# Add compiled resources if any
|
# Add compiled resources if any
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|||||||
Reference in New Issue
Block a user