fix(release): require committed versionName for tag builds#155
Conversation
Greptile SummaryThis PR fixes the release workflow so it verifies the committed
Confidence Score: 5/5The changes are safe to merge — the version-check logic is well-guarded, the emulator bootstrap fixes are correct, and the PR-guard conditions prevent secret-dependent steps from running on contributor PRs. The version verification logic handles both quote styles and guards against an empty parse result before reaching the tag comparison. The emulator path resolution now correctly happens after sdkmanager installs the package. The artifact rename and v4 upgrade follow the correct multi-artifact pattern. No regressions were identified across the changed paths. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Push event] --> B{Is tag refs/tags/v*?}
B -- No --> C[build-apk: skip version check\nuse committed versionName]
B -- Yes --> D[Verify versionName matches tag]
D --> E{COMMITTED_VERSION\nparseable?}
E -- No --> F[Exit 1: Failed to parse versionName]
E -- Yes --> G{COMMITTED_VERSION == SHORT_VERSION?}
G -- No --> H[Exit 1: versionName must match tag]
G -- Yes --> I[Continue build]
I --> J[Set versionCode]
J --> K[Assemble APK/AAB]
K --> L[Upload artifact: aw-android-apk / aw-android-aab]
L --> M[release-fastlane / release-gh]
Reviews (9): Last reviewed commit: "fix(ci): treat emulator accel check as a..." | Re-trigger Greptile |
| COMMITTED_VERSION=$(sed -n 's/^[[:space:]]*versionName "\(.*\)"/\1/p' mobile/build.gradle) | ||
| if [ "$COMMITTED_VERSION" != "$SHORT_VERSION" ]; then | ||
| echo "mobile/build.gradle versionName must match the release tag." | ||
| echo "tag=$SHORT_VERSION committed=$COMMITTED_VERSION" | ||
| exit 1 |
There was a problem hiding this comment.
Silent empty-string on pattern mismatch
If the versionName line ever uses single quotes (valid Groovy DSL: versionName '0.12.1') or is formatted in a way the regex doesn't cover, COMMITTED_VERSION will silently be an empty string. The subsequent mismatch message prints committed= with no value, which makes it hard to distinguish "version doesn't match" from "sed extracted nothing". Adding an explicit empty-string guard before the comparison would make the failure self-explanatory.
There was a problem hiding this comment.
Already handled on this branch in 12c757c. The workflow now exits immediately when versionName cannot be parsed, before it reaches the tag/version mismatch check.
| EMULATOR="$(find_android_tool "$ANDROID_HOME/emulator/emulator" emulator)" | ||
|
|
||
| # Install AVD files | ||
| echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-'$MATRIX_E_SDK';default;x86_64' | ||
| echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses | ||
| echo "y" | "$SDKMANAGER" --install \ | ||
| emulator \ | ||
| 'system-images;android-'$MATRIX_E_SDK';default;x86_64' |
There was a problem hiding this comment.
EMULATOR resolved before sdkmanager --install emulator
android-actions/setup-android@v2 installs cmdline-tools and platform-tools but does NOT install the emulator package. The find_android_tool call for EMULATOR on line 368 runs before sdkmanager --install emulator on line 371–372, so $ANDROID_HOME/emulator/emulator won't exist yet and emulator won't be in PATH either. With set -e active, the script exits immediately at the variable assignment — the sdkmanager install line is never reached, and every test run fails at this step. The resolution of EMULATOR should be moved to after the sdkmanager --install call.
| EMULATOR="$(find_android_tool "$ANDROID_HOME/emulator/emulator" emulator)" | |
| # Install AVD files | |
| echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-'$MATRIX_E_SDK';default;x86_64' | |
| echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses | |
| echo "y" | "$SDKMANAGER" --install \ | |
| emulator \ | |
| 'system-images;android-'$MATRIX_E_SDK';default;x86_64' | |
| SDKMANAGER="$(find_android_tool "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" sdkmanager)" | |
| AVDMANAGER="$(find_android_tool "$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager" avdmanager)" | |
| # Install AVD files | |
| echo "y" | "$SDKMANAGER" --install \ | |
| emulator \ | |
| 'system-images;android-'$MATRIX_E_SDK';default;x86_64' | |
| echo "y" | "$SDKMANAGER" --licenses | |
| # Resolve emulator path after installation | |
| EMULATOR="$(find_android_tool "$ANDROID_HOME/emulator/emulator" emulator)" | |
| # Create emulator | |
| "$AVDMANAGER" create avd -n $MATRIX_AVD -d pixel --package 'system-images;android-'$MATRIX_E_SDK';default;x86_64' | |
| "$EMULATOR" -list-avds |
There was a problem hiding this comment.
- Verify committed versionName matches the release tag instead of rewriting mobile/build.gradle during CI (keeps tagged source, GitHub releases, and F-Droid builds on the same version) - Update README with pre-tag versionName update step - Update mobile/build.gradle versionName comment to reflect new workflow Closes ActivityWatch#24.
b74ade3 to
5c110cf
Compare
|
Rebased onto current master to resolve conflicts. The rebase squashed the branch's history into a single clean commit — the core change (verify committed |
|
@TimeToBuildBob Merged, this is fine but we want the release process to become fully automated, which would require us writing/pushing a commit updating this in CI before building. Make the follow-up PR that makes it so that someone doesn't have to manually master-push a version bump before triggering a release such as by pushing a version tag or workflow_trigger'ing a CI release job which does it. Might want to take inspiration from the CI in the main/bundle ActivityWatch (and core gptme) repos. |
|
Follow-up PR created: #168 (feat(release): auto-set versionName from tag on release builds) Changes:
No manual build.gradle edit needed anymore — just git tag -s v0.x.y && git push origin refs/tags/v0.x.y |
The 'Set versionName from tag' sed regex introduced in this PR had a
bug: the substitution matched up to but not including the closing quote
of the existing versionName, so after substitution the line became
versionName '0.x.y'"
(dangling closing quote), a Groovy syntax error that breaks Gradle.
F-Droid also requires the correct versionName in the committed source
that the tag points to, so patching it post-checkout never helped there.
Fix: revert the verify-before-tag step from ActivityWatch#155, and add a new
.github/workflows/release.yml with a workflow_dispatch trigger that
does the whole release atomically:
1. Validates the version format and that the tag does not exist yet
2. Updates versionName in mobile/build.gradle with a correct sed that
consumes both surrounding quotes (no dangling characters)
3. Commits the change and pushes a signed annotated tag
4. The tag push (via RELEASE_PAT) triggers the Build workflow
This satisfies F-Droid: the tag now always points to a commit where
the versionName matches. Requires a RELEASE_PAT secret (repo-scoped
GitHub PAT) — documented in README and release.yml.
* feat(release): auto-set versionName from tag on release builds
* fix(release): replace broken sed with workflow_dispatch release flow
The 'Set versionName from tag' sed regex introduced in this PR had a
bug: the substitution matched up to but not including the closing quote
of the existing versionName, so after substitution the line became
versionName '0.x.y'"
(dangling closing quote), a Groovy syntax error that breaks Gradle.
F-Droid also requires the correct versionName in the committed source
that the tag points to, so patching it post-checkout never helped there.
Fix: revert the verify-before-tag step from #155, and add a new
.github/workflows/release.yml with a workflow_dispatch trigger that
does the whole release atomically:
1. Validates the version format and that the tag does not exist yet
2. Updates versionName in mobile/build.gradle with a correct sed that
consumes both surrounding quotes (no dangling characters)
3. Commits the change and pushes a signed annotated tag
4. The tag push (via RELEASE_PAT) triggers the Build workflow
This satisfies F-Droid: the tag now always points to a commit where
the versionName matches. Requires a RELEASE_PAT secret (repo-scoped
GitHub PAT) — documented in README and release.yml.
Summary
mobile/build.gradleversionNameduring tag buildsversionNamedoes not match thev*tagCloses #24.