refactor: unify release workflow to tag-based trigger#521
Conversation
Closes #520 - Add release.yml: single tag-based workflow that builds Android APK/AAB, generates changelog, updates pubspec.yaml, creates GitHub Release, and triggers desktop builds via repository_dispatch - Simplify main.yml: remove release logic, keep as CI build check only - Update desktop.yml: remove direct tag trigger (now triggered by release.yml via repository_dispatch + manual workflow_dispatch) Release flow: git tag v1.2.1 && git push --tags → everything automatic
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR unifies the release workflow by removing release logic from main.yml, introducing a new tag-based release.yml workflow that handles Android builds, versioning, changelog generation, and GitHub release creation, while removing tag-push triggers from desktop.yml. Changes
Sequence Diagram(s)sequenceDiagram
participant Git as Git Repository
participant GH as GitHub Actions
participant Build as Flutter Builder
participant Sign as APK/AAB Signer
participant Release as GitHub Release API
participant Desktop as Desktop Workflow
Git->>GH: Tag push (v1.2.1)
activate GH
GH->>Git: Extract version from tag
GH->>Git: Parse commits for changelog
GH->>Git: Bump pubspec.yaml version
GH->>Git: Commit & push to main
deactivate GH
activate GH
GH->>Build: Setup Flutter & Android
Build->>Build: flutter build apk --split-per-abi
Build->>Build: flutter build appbundle
GH->>Sign: Verify APK/AAB signatures
Sign->>GH: Signing verified
deactivate GH
activate GH
GH->>Release: Create GitHub Release
Release->>Release: Attach APKs, AAB, release notes
deactivate GH
activate GH
GH->>Desktop: Trigger desktop builds (repository_dispatch)
Desktop->>Desktop: Build Linux/macOS/Windows
deactivate GH
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/release.yml (1)
159-163: Consider addingflutter analyzeandflutter testbefore release builds.While the assumption is that code was validated before the tag was created, adding these checks here provides a final safety gate before publishing artifacts. This prevents releasing broken builds if someone tags an unvalidated commit.
Suggested addition after dependencies
- name: Generate localization and other required files run: dart run build_runner build -d + - name: Analyze code + run: flutter analyze + + - name: Run tests + run: flutter test + - name: Update version in pubspec for build🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 159 - 163, Add two CI steps after the "Install dependencies" step to run static analysis and unit tests: add a step named "Analyze" that runs "flutter analyze" and a step named "Run tests" that runs "flutter test" (optionally with --coverage or --no-test-assets as needed). Ensure these steps are placed before the "Generate localization and other required files" step so the workflow stops the release if analysis or tests fail..github/workflows/main.yml (1)
42-49: Consider addingflutter analyzeandflutter testto the CI check.This workflow runs on every push to
mainbut only performs a debug build. Per coding guidelines,flutter analyzeandflutter testare mandatory before commits. Adding these steps would catch lint issues and test regressions early, strengthening the CI gate.Suggested additions before the build step
- name: Generate localization and other required files run: dart run build_runner build -d + - name: Analyze code + run: flutter analyze + + - name: Run tests + run: flutter test + - name: Build APK (debug check) run: flutter build apk --debugBased on learnings: "Always run
flutter analyzeafter any code change - it is mandatory before commits" and "Always runflutter testafter any code change - it is mandatory before commits."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/main.yml around lines 42 - 49, Add CI steps to run static analysis and unit/widget tests before the build step: insert two steps named "Run flutter analyze" (command: flutter analyze) and "Run flutter test" (command: flutter test --no-sound-null-safety or as appropriate) prior to the "Build APK (debug check)" step so the workflow fails on lint or test failures; reference the existing step names "Install Dependencies", "Generate localization and other required files", and "Build APK (debug check)" to position the new steps in the correct order and ensure they run after dependencies are installed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yml:
- Around line 101-110: The workflow currently runs the sed version update while
on the tag and then runs git checkout main and git merge --ff-only with a
trailing "|| true", which can overwrite or lose the pubspec.yaml change and
silently ignore merge failures; modify the "Commit version bump to main" step so
that you first fetch and checkout main (git fetch origin main; git checkout
main), then perform the sed update of pubspec.yaml (apply the version bump)
while on main, remove the "|| true" from git merge --ff-only ${{
steps.version.outputs.full_tag }} so the job fails if fast-forward merge is not
possible (or replace with an explicit rebase/merge strategy), then git add
pubspec.yaml, git diff --cached --quiet || git commit -m "chore: update version
for ${{ steps.version.outputs.full_tag }}", and git push origin main to ensure
the bump is applied on main and merge problems are surfaced.
---
Nitpick comments:
In @.github/workflows/main.yml:
- Around line 42-49: Add CI steps to run static analysis and unit/widget tests
before the build step: insert two steps named "Run flutter analyze" (command:
flutter analyze) and "Run flutter test" (command: flutter test
--no-sound-null-safety or as appropriate) prior to the "Build APK (debug check)"
step so the workflow fails on lint or test failures; reference the existing step
names "Install Dependencies", "Generate localization and other required files",
and "Build APK (debug check)" to position the new steps in the correct order and
ensure they run after dependencies are installed.
In @.github/workflows/release.yml:
- Around line 159-163: Add two CI steps after the "Install dependencies" step to
run static analysis and unit tests: add a step named "Analyze" that runs
"flutter analyze" and a step named "Run tests" that runs "flutter test"
(optionally with --coverage or --no-test-assets as needed). Ensure these steps
are placed before the "Generate localization and other required files" step so
the workflow stops the release if analysis or tests fail.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5cc8fdc3-4a7d-45b6-a00b-a0f2380597d1
📒 Files selected for processing (3)
.github/workflows/desktop.yml.github/workflows/main.yml.github/workflows/release.yml
💤 Files with no reviewable changes (1)
- .github/workflows/desktop.yml
| - name: Commit version bump to main | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git fetch origin main | ||
| git checkout main | ||
| git merge --ff-only ${{ steps.version.outputs.full_tag }} || true | ||
| git add pubspec.yaml | ||
| git diff --cached --quiet || git commit -m "chore: update version for ${{ steps.version.outputs.full_tag }}" | ||
| git push origin main |
There was a problem hiding this comment.
Potential issue: version bump may be lost due to checkout sequencing.
The sed command updates pubspec.yaml while checked out at the tag (lines 94-99). Then git checkout main (line 106) may overwrite the working tree, potentially losing the sed changes if the pubspec differs between the tag and main.
Additionally, || true on the merge (line 107) silently swallows failures—if main has diverged and fast-forward isn't possible, the workflow continues without properly merging, which could leave pubspec.yaml in an inconsistent state.
Suggested fix: restructure to apply version bump after checkout
- name: Commit version bump to main
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin main
git checkout main
- git merge --ff-only ${{ steps.version.outputs.full_tag }} || true
+ git merge --ff-only ${{ steps.version.outputs.full_tag }}
+
+ # Apply version bump after checkout
+ VERSION=${{ steps.version.outputs.tag }}
+ BUILD=$(git rev-list --count HEAD)
+ sed -i "s/^version: .*/version: ${VERSION}+${BUILD}/" pubspec.yaml
+
git add pubspec.yaml
git diff --cached --quiet || git commit -m "chore: update version for ${{ steps.version.outputs.full_tag }}"
git push origin mainThis ensures the version bump is applied after checking out main, and removes the silent failure on merge. If you want to handle diverged branches gracefully, consider a rebase or explicit error handling.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Commit version bump to main | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin main | |
| git checkout main | |
| git merge --ff-only ${{ steps.version.outputs.full_tag }} || true | |
| git add pubspec.yaml | |
| git diff --cached --quiet || git commit -m "chore: update version for ${{ steps.version.outputs.full_tag }}" | |
| git push origin main | |
| - name: Commit version bump to main | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin main | |
| git checkout main | |
| git merge --ff-only ${{ steps.version.outputs.full_tag }} | |
| # Apply version bump after checkout | |
| VERSION=${{ steps.version.outputs.tag }} | |
| BUILD=$(git rev-list --count HEAD) | |
| sed -i "s/^version: .*/version: ${VERSION}+${BUILD}/" pubspec.yaml | |
| git add pubspec.yaml | |
| git diff --cached --quiet || git commit -m "chore: update version for ${{ steps.version.outputs.full_tag }}" | |
| git push origin main |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/release.yml around lines 101 - 110, The workflow currently
runs the sed version update while on the tag and then runs git checkout main and
git merge --ff-only with a trailing "|| true", which can overwrite or lose the
pubspec.yaml change and silently ignore merge failures; modify the "Commit
version bump to main" step so that you first fetch and checkout main (git fetch
origin main; git checkout main), then perform the sed update of pubspec.yaml
(apply the version bump) while on main, remove the "|| true" from git merge
--ff-only ${{ steps.version.outputs.full_tag }} so the job fails if fast-forward
merge is not possible (or replace with an explicit rebase/merge strategy), then
git add pubspec.yaml, git diff --cached --quiet || git commit -m "chore: update
version for ${{ steps.version.outputs.full_tag }}", and git push origin main to
ensure the bump is applied on main and merge problems are surfaced.
There was a problem hiding this comment.
Good catch. Fixed in f3f9566 — version bump now happens after git checkout main, and removed || true from the merge so diverged branches fail fast instead of silently continuing.
- Move sed version update to after git checkout main (prevents overwrite) - Remove || true from ff-only merge (fail fast on diverged branches) - Consolidate version bump into the commit step
- main.yml: run flutter analyze + flutter test before debug build - release.yml: run flutter analyze + flutter test after code gen, before APK build - Ensures releases and CI builds fail on lint/test issues
Closes #520
Summary
Unifies the release process into a single tag-based workflow. Before: 3 manual steps (edit pubspec.yaml, push to main, create tag). After: 1 step (
git tag v1.2.1 && git push --tags).Changes
.github/workflows/release.yml(NEW)Single tag-based workflow that:
pubspec.yamland commits to mainrepository_dispatch.github/workflows/main.yml(SIMPLIFIED).github/workflows/desktop.yml(UPDATED)repository_dispatchfromrelease.yml+ manualworkflow_dispatch.github/workflows/flutter.yml(UNCHANGED)Signing
Same secrets as before — no changes needed:
ANDROID_KEYSTORE_FILEANDROID_KEYSTORE_PASSWORDANDROID_KEY_PASSWORDANDROID_KEY_ALIASRelease Flow
The workflow will: build Android APKs → verify signing → generate changelog → update pubspec.yaml on main → create GitHub Release → trigger desktop builds.
Testing
workflow_dispatchonrelease.ymlis NOT enabled intentionally (releases should always come from tags)workflow_dispatchondesktop.ymlSummary by CodeRabbit