Skip to content

Commit e472a9f

Browse files
committed
Show a real version name on Android builds instead of the run number
The rolling APK workflow passed the CI run number as both versionCode and versionName, so the app reported its version as "117". Keep the increasing code as CI's job, but compose the user-visible name in gradle from a single base version: rolling builds now show "0.1.1 (build N)" so testers can still report the exact build. Also treat blank ANDROID_VERSION_CODE/NAME env vars as absent: the release workflow forwards optional inputs verbatim, so a blank input used to produce an empty versionName (and a NumberFormatException on the code) instead of falling back to the gradle default.
1 parent fd530db commit e472a9f

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/android-apk.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ jobs:
154154
# Keep the rolling sideload APK installable over previous team builds. Without this,
155155
# debug builds fall back to versionCode 1 and Android refuses to update any tester
156156
# who already has a newer local or Play-signed build installed.
157+
# versionName is composed in build.gradle.kts ("0.1.1 (build N)"); only the
158+
# strictly increasing code is CI's job.
157159
ANDROID_VERSION_CODE: ${{ github.run_number }}
158-
ANDROID_VERSION_NAME: ${{ github.run_number }}
159160
run: ./gradlew --no-daemon assembleDebug
160161

161162
# SHA-1 is a public fingerprint (not the key), safe to log — proves the team key signed it.

surfaces/android/app/build.gradle.kts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ android {
4242
targetSdk = 35
4343
// Play requires a strictly increasing versionCode for every upload to a track. CI passes
4444
// the next number via ANDROID_VERSION_CODE; local/debug builds fall back to 1 unchanged.
45-
versionCode = (providers.environmentVariable("ANDROID_VERSION_CODE").orNull
46-
?: localProperties.getProperty("versionCode"))?.toInt() ?: 1
47-
versionName = providers.environmentVariable("ANDROID_VERSION_NAME").orNull
48-
?: localProperties.getProperty("versionName", "0.1.0")
45+
// Workflows pass optional inputs straight through as env vars, so a blank input
46+
// arrives as an empty string, not an unset var; treat blank as absent or the
47+
// release workflow's "blank = keep gradle default" promise silently breaks.
48+
val ciBuild = providers.environmentVariable("ANDROID_VERSION_CODE").orNull?.takeIf { it.isNotBlank() }
49+
versionCode = (ciBuild ?: localProperties.getProperty("versionCode"))?.toInt() ?: 1
50+
// The marketing version lives HERE (single source); the release workflow can still
51+
// override it via ANDROID_VERSION_NAME. Rolling CI builds append their run number so
52+
// testers can report exactly which build they have ("0.1.1 (build 117)"), instead of
53+
// the old behavior of showing the bare run number as the whole version.
54+
val baseVersion = localProperties.getProperty("versionName", "0.1.1")
55+
versionName = providers.environmentVariable("ANDROID_VERSION_NAME").orNull?.takeIf { it.isNotBlank() }
56+
?: if (ciBuild != null) "$baseVersion (build $ciBuild)" else baseVersion
4957
buildConfigField(
5058
"String",
5159
"GOOGLE_OAUTH_CLIENT_ID",

0 commit comments

Comments
 (0)