chore(android): allow versionName to be set at build time - #4550
Conversation
## Related issue N/A — build configuration chore. ## Summary - `versionCode` was already overridable with `-PversionCode=…`, but `versionName` was a hardcoded literal, so every release build required editing `app/build.gradle.kts` and committing the bump. Both are now overridable at build time, with the checked-in values as defaults. - Added a `buildProperty()` helper that reads a Gradle property and treats blank as absent. This also fixes an existing rough edge: `-PversionCode=` with an empty value (what the CI workflow passes on PR-triggered runs, where the dispatch inputs are unset) was taken literally instead of falling back. - Threaded a new optional `version-name` input through the `Android Bundle` workflow and quoted both `-P` args so an empty value stays a single token. - Documented the override in `web/android/README.md` under a new "Versioning" heading, and removed the two now-stale "bump `versionCode` in `app/build.gradle.kts` before each upload" instructions. Note: the repo's `Bump Version` workflow still only bumps the Python packages, so the checked-in `versionName` default can drift from the release version. Folding Android into `scripts/update_versions.py` is left for a follow-up. ## Test Plan Verified the property plumbing at configuration time with a throwaway Gradle init script that reflects into `android.defaultConfig` and prints the resolved values: ```sh cd web/android ./gradlew -I /tmp/print-version.gradle.kts help -q # name=0.1.3 code=9 ./gradlew -I /tmp/print-version.gradle.kts help -q \ -PversionCode=42 -PversionName=9.9.9-rc1 # name=9.9.9-rc1 code=42 ./gradlew -I /tmp/print-version.gradle.kts help -q "-PversionCode=" "-PversionName=" # name=0.1.3 code=9 ``` All three matched expectations: defaults apply with no flags, overrides take effect, and blank values fall back to the defaults (the CI PR-event path). `pre-commit run --files …` passes; ktlint rewrapped the helper's signature. ## Demo N/A — no user-visible surface; build configuration only. ## Type of change - [ ] Bug fix - [ ] Feature - [ ] UI / frontend change - [x] Refactor / chore - [ ] Docs - [ ] Test / CI - [ ] Breaking change ## Test coverage - [ ] Unit tests added / updated - [ ] Integration tests added / updated - [ ] E2E tests added / updated - [x] Manual verification completed - [ ] Existing tests cover this change - [ ] Not applicable ## Coverage notes The change is Gradle build configuration, which the test suites do not cover. Verified manually via the three `./gradlew` invocations above, asserting the resolved `versionCode`/`versionName` for the default, overridden, and blank-value cases. The existing `Android Bundle` workflow also runs `bundleRelease` on PRs touching `web/android/**`, so this PR exercises the blank-input path in CI. Signed-off-by: Zeyi (Rice) Fan <zeyi.f@databricks.com>
|
|
🏷️ Doc impact: This only changes Android build/versioning tooling (CI workflow input, Gradle version overrides, and the internal Auto-classified on merge. Set the label manually before merging to override. · run |
Related issue
N/A — build configuration chore.
Summary
versionCodewas already overridable with-PversionCode=…, butversionNamewas a hardcoded literal, so every release build required editing
app/build.gradle.ktsand committing the bump. Both are now overridable atbuild time, with the checked-in values as defaults.
buildProperty()helper that reads a Gradle property and treats blankas absent. This also fixes an existing rough edge:
-PversionCode=with anempty value (what the CI workflow passes on PR-triggered runs, where the
dispatch inputs are unset) was taken literally instead of falling back.
version-nameinput through theAndroid Bundleworkflow and quoted both
-Pargs so an empty value stays a single token.web/android/README.mdunder a new "Versioning"heading, and removed the two now-stale "bump
versionCodeinapp/build.gradle.ktsbefore each upload" instructions.Note: the repo's
Bump Versionworkflow still only bumps the Python packages, sothe checked-in
versionNamedefault can drift from the release version. FoldingAndroid into
scripts/update_versions.pyis left for a follow-up.Test Plan
Verified the property plumbing at configuration time with a throwaway Gradle init
script that reflects into
android.defaultConfigand prints the resolved values:All three matched expectations: defaults apply with no flags, overrides take
effect, and blank values fall back to the defaults (the CI PR-event path).
pre-commit run --files …passes; ktlint rewrapped the helper's signature.Demo
N/A — no user-visible surface; build configuration only.
Type of change
Test coverage
Coverage notes
The change is Gradle build configuration, which the test suites do not cover.
Verified manually via the three
./gradlewinvocations above, asserting theresolved
versionCode/versionNamefor the default, overridden, andblank-value cases. The existing
Android Bundleworkflow also runsbundleReleaseon PRs touchingweb/android/**, so this PR exercises theblank-input path in CI.