fix: release workflow — prevent double build number and fix changelog#524
Conversation
… generation
Problems fixed:
1. Tag pattern now only matches semver (v1.2.3), NOT v1.2.3+456
- Prevents phantom workflow runs from build-metadata tags
2. Version extraction strips any build metadata from tag
- TAG=v1.2.1+936 → version=1.2.1 (defensive, belt-and-suspenders)
3. CHANGELOG.md generated on main after checkout (not on tag)
- Previous version generated CHANGELOG on tag checkout, then
git checkout main overwrote it
4. Previous tag filter only considers clean semver tags
- Prevents v1.2.1+936 from being picked as prev_tag
5. Exclude chore: update changelog commits from changelog
6. Revert corrupted pubspec.yaml (1.2.1+936+943 → 1.2.0+2)
Root cause of the corruption:
- Tag v1.2.1+936 (created by old desktop.yml) was not deleted
- When v1.2.1 was pushed, both tags triggered release.yml
- v1.2.1+936 run set VERSION=1.2.1+936, producing 1.2.1+936+BUILD
- This was pushed to main, corrupting pubspec.yaml
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe release workflow was refactored to enforce strict semantic version tag matching (vX.Y.Z), improved version extraction by stripping build metadata, and restored CHANGELOG.md generation on the main branch by parsing RELEASE_NOTES.md into categorized sections. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
🧹 Nitpick comments (1)
.github/workflows/release.yml (1)
207-211: Fragile header-skip assumption could duplicate or lose content.
tail -n +7assumes the existing CHANGELOG.md has exactly 6 header lines. If the header format varies (e.g., different number of blank lines, additional metadata), this could either duplicate header content or skip actual changelog entries.Consider a more robust approach that finds the first version entry dynamically:
♻️ Proposed fix using pattern-based skip
- # Append previous changelog content (skip the header block — first 6 lines) - if [ -f CHANGELOG.md ]; then - tail -n +7 CHANGELOG.md - fi + # Append previous changelog content (skip header, start from first version entry) + if [ -f CHANGELOG.md ]; then + # Find line number of first "## [" (version entry) and print from there + FIRST_VERSION_LINE=$(grep -n '^## \[' CHANGELOG.md | head -1 | cut -d: -f1) + if [ -n "$FIRST_VERSION_LINE" ]; then + tail -n +"$FIRST_VERSION_LINE" CHANGELOG.md + fi + fi🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 207 - 211, The current use of "tail -n +7 CHANGELOG.md" is fragile; update the block that writes to CHANGELOG_NEW.md to dynamically find the first version heading instead of assuming 6 header lines — detect the first changelog entry by matching a version heading pattern (e.g., a line matching '^## \[' or '^#\s*[0-9]\+' / '^##\s*\\[') and print the file starting from that matched line; replace the "tail -n +7 CHANGELOG.md" invocation with a pattern-based command (awk/sed/grep) that searches CHANGELOG.md for the first version header and outputs from there into CHANGELOG_NEW.md so headers are neither duplicated nor accidentally skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 207-211: The current use of "tail -n +7 CHANGELOG.md" is fragile;
update the block that writes to CHANGELOG_NEW.md to dynamically find the first
version heading instead of assuming 6 header lines — detect the first changelog
entry by matching a version heading pattern (e.g., a line matching '^## \[' or
'^#\s*[0-9]\+' / '^##\s*\\[') and print the file starting from that matched
line; replace the "tail -n +7 CHANGELOG.md" invocation with a pattern-based
command (awk/sed/grep) that searches CHANGELOG.md for the first version header
and outputs from there into CHANGELOG_NEW.md so headers are neither duplicated
nor accidentally skipped.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bc0aec57-b761-4c0f-a78f-c18978477e60
📒 Files selected for processing (2)
.github/workflows/release.ymlpubspec.yaml
Problems Fixed
1. 🚨 Double build number (
1.2.1+936+943)Root cause: Tag
v1.2.1+936(created by olddesktop.yml) was not deleted before pushingv1.2.1. Both tags triggeredrelease.ymlsimultaneously. Thev1.2.1+936run extractedTAG=1.2.1+936and the sed produced1.2.1+936+BUILD.Fix: Tag pattern now only matches clean semver:
v[0-9]+.[0-9]+.[0-9]+(notv1.2.3+456). Additionally, version extraction strips any+metadata defensively.2. Empty CHANGELOG sections
Root cause: CHANGELOG was generated during the tag checkout phase. Then
git checkout mainoverwrote it.Fix: CHANGELOG is now generated AFTER
git checkout mainand merge, using the same categorized data fromRELEASE_NOTES.md.3. Previous tag picking up build-metadata tags
Fix:
PREV_TAGfilter now only considers clean semver tags (^v[0-9]+\.[0-9]+\.[0-9]+$).4. Corrupted pubspec.yaml
Reverted
1.2.1+936+943→1.2.0+2.After merging
v1.2.1:git push origin --delete v1.2.1v1.2.1release from GitHubgit tag -a v1.2.1 -m "v1.2.1" && git push origin v1.2.1Summary by CodeRabbit