Skip to content

fix(release): require committed versionName for tag builds#155

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:bob/fdroid-versionname-pre-tag
Jul 1, 2026
Merged

fix(release): require committed versionName for tag builds#155
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:bob/fdroid-versionname-pre-tag

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Summary

  • stop rewriting mobile/build.gradle versionName during tag builds
  • fail tag workflows when the committed versionName does not match the v* tag
  • document the pre-tag release step so tagged source, GitHub releases, and F-Droid builds stay aligned

Closes #24.

@greptile-apps

greptile-apps Bot commented May 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes the release workflow so it verifies the committed versionName in mobile/build.gradle matches the git tag instead of silently patching the file at build time, ensuring tagged source, GitHub release builds, and F-Droid builds all reflect the same version.

  • Version check: The "Set versionName" step is replaced with "Verify versionName matches tag" — the workflow now fails fast with a clear diagnostic if the committed value doesn't match the v* tag, and the README documents the pre-tag bump requirement.
  • Emulator setup: The test-e2e emulator bootstrap is rewritten using android-actions/setup-android@v2 and a find_android_tool helper, resolving the emulator binary after sdkmanager installs it, guarding screencapture on non-macOS runners, and upgrading all artifact actions from v3 to v4.
  • PR safety: setup-age-action, Load Fastlane secrets, and Update versionCode are now all gated with if: github.event_name != 'pull_request', preventing secret-dependent steps from blocking CI on contributor PRs.

Confidence Score: 5/5

The 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

Filename Overview
.github/workflows/build.yml Core workflow changes: versionName verification instead of patching, PR guards on secret-dependent steps, emulator bootstrap rewrite with proper tool resolution order, artifact v3 to v4 upgrade, and Rust toolchain pinned to 1.79.0 to match submodule constraints. All logic is correct.
mobile/build.gradle Comment updated to reflect that versionName is now source-of-truth; the stale FIXME referencing CI-set version is removed. No functional code changes.
README.md Release instructions updated to document the required pre-tag versionName bump, aligning developer guidance with the new workflow enforcement.

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]
Loading

Reviews (9): Last reviewed commit: "fix(ci): treat emulator accel check as a..." | Re-trigger Greptile

Comment thread .github/workflows/build.yml Outdated
Comment on lines +197 to +201
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/build.yml Outdated
Comment on lines +368 to +373
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'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Suggested change
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

@TimeToBuildBob TimeToBuildBob May 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in follow-up commits 814df08 and b74ade3. The workflow now resolves the emulator path only after sdkmanager installs it, uses the documented -accel-check form, and treats the acceleration probe as advisory so runners without KVM access can continue booting the AVD.

- 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.
@TimeToBuildBob TimeToBuildBob force-pushed the bob/fdroid-versionname-pre-tag branch from b74ade3 to 5c110cf Compare June 29, 2026 22:14
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Rebased onto current master to resolve conflicts. The rebase squashed the branch's history into a single clean commit — the core change (verify committed versionName matches the release tag instead of rewriting build.gradle in CI) is unchanged. CI running now.

@ErikBjare ErikBjare merged commit dbd05d1 into ActivityWatch:master Jul 1, 2026
7 checks passed
@ErikBjare

Copy link
Copy Markdown
Member

@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.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Follow-up PR created: #168 (feat(release): auto-set versionName from tag on release builds)

Changes:

  • Replaced "Verify versionName matches tag" with "Set versionName from tag"
  • On tag pushes, CI auto-updates versionName to match the tag before building
  • Updated README release docs accordingly
  • PR/non-tag builds unaffected

No manual build.gradle edit needed anymore — just git tag -s v0.x.y && git push origin refs/tags/v0.x.y

TimeToBuildBob added a commit to TimeToBuildBob/aw-android that referenced this pull request Jul 1, 2026
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.
ErikBjare pushed a commit that referenced this pull request Jul 1, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Submit to F-droid repos

2 participants