Include Android versionCode in APK and AAB artifact names

This commit is contained in:
Joe Tretter
2026-05-18 19:46:31 -05:00
parent afb548d46f
commit 9bf1d610f8
3 changed files with 32 additions and 5 deletions

View File

@@ -253,6 +253,21 @@ print(f'Updated versionCode to {new_code} and versionName to {new_name}')
PY
}
android_version_code() {
local gradle_file="$PROJECT_DIR/app/build.gradle.kts"
python - <<PY
from pathlib import Path
import re
path = Path(r'''$gradle_file''')
text = path.read_text()
match = re.search(r'versionCode\s*=\s*(\d+)', text)
if not match:
raise SystemExit('Could not find versionCode in app/build.gradle.kts')
print(match.group(1))
PY
}
setup_env() {
setup_java_env
export ANDROID_HOME="$SDK_DIR"
@@ -521,6 +536,18 @@ maybe_run_operation() {
if [ "$should_bump_version" = "true" ]; then
bump_android_version
fi
if [ -n "$artifact_source" ]; then
local version_code
version_code="$(android_version_code)"
case "$mode" in
--build)
artifact_target="$PROJECT_DIR/app/build/outputs/apk/debug/githug-android-debug-v${version_code}.apk"
;;
--build-release-aab)
artifact_target="$PROJECT_DIR/app/build/outputs/bundle/release/githug-android-release-v${version_code}.aab"
;;
esac
fi
if [ "$should_compile_host_git" = "true" ]; then
build_host_git
export GITHUG_TEST_GIT_BINARY="$HOST_GIT_BINARY"