fdroid-publish: read versionCode with Debian aapt when the SDK is absent (promote runs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sysadminandClaude Opus 5.5 committed 2026-09-30 21:29:26 +01:00
1 parent 240830a324
commit 624415406f
1 file changed
+9 -1
+9 -1
View File
@@ -70,9 +70,17 @@ else
fi fi
if [ -z "$version_code" ]; then if [ -z "$version_code" ]; then
if aapt=$(find_tool aapt2 || find_tool aapt); then # Needed for the no-downgrade guard below. A bare runner image (the promote
# workflow's) has no Android SDK, so fetch Debian's aapt rather than guess.
if ! aapt=$(find_tool aapt2 || find_tool aapt); then
SUDO=; [ "$(id -u)" -eq 0 ] || SUDO=sudo
{ $SUDO apt-get update -qq && $SUDO apt-get install -y -qq aapt; } >/dev/null 2>&1 || true
aapt=$(command -v aapt || true)
fi
if [ -n "${aapt:-}" ]; then
version_code=$("$aapt" dump badging "$apk" 2>/dev/null | sed -n "s/.*versionCode='\([0-9]*\)'.*/\1/p" | head -n1) version_code=$("$aapt" dump badging "$apk" 2>/dev/null | sed -n "s/.*versionCode='\([0-9]*\)'.*/\1/p" | head -n1)
fi fi
[ -n "$version_code" ] || say "::warning::could not read the APK's versionCode — the no-downgrade guard is off for this run"
fi fi
head_code() { # highest versionCode the channel serves for $pkg (0 if none) head_code() { # highest versionCode the channel serves for $pkg (0 if none)