-
Notifications
You must be signed in to change notification settings - Fork 1
fix: auto-bump patch version in release workflow #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, when the Release workflow was triggered by workflow_run (after CI completes on main), it would skip the release if the current version tag already existed. This required manual version bumps before each release. Now, when triggered by workflow_run: - If current version tag doesn't exist → release with current version - If current version tag exists → auto-bump patch version, update Cargo.toml, then release This makes releases fully automatic after merging PRs to main.
WalkthroughThe release workflow now automatically bumps the patch version when an existing version tag is encountered during workflow runs, rather than skipping the release. The logic parses the current version, increments the patch component, and sets the appropriate release and bump flags accordingly. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks✅ Passed checks (3 passed)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/release.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
| echo "Tag v$CURRENT_VERSION already exists, auto-bumping patch version" | ||
| # Auto-bump patch version | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | ||
| NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" | ||
| echo "Auto-bumped to: $NEW_VERSION" | ||
| echo "should_release=true" >> $GITHUB_OUTPUT | ||
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
| echo "needs_bump=true" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/release.yml | head -150Repository: rishitank/context-engine
Length of output: 6379
🏁 Script executed:
cat -n .github/workflows/release.yml | tail -100Repository: rishitank/context-engine
Length of output: 4105
🏁 Script executed:
cat Cargo.toml | head -20Repository: rishitank/context-engine
Length of output: 582
🏁 Script executed:
# Check if there are any other version validations in the codebase
grep -r "version" .github/workflows/ --include="*.yml" | grep -E "(validate|regex|match|semver)" || echo "No regex-based version validation found"Repository: rishitank/context-engine
Length of output: 107
🏁 Script executed:
# Verify the complete auto-bump logic in both workflow_dispatch and workflow_run contexts
cat -n .github/workflows/release.yml | sed -n '71,92p'Repository: rishitank/context-engine
Length of output: 1009
🏁 Script executed:
# Check how release job handles version tag creation and potential conflicts
cat -n .github/workflows/release.yml | sed -n '433,449p'Repository: rishitank/context-engine
Length of output: 859
Validate version format and prevent concurrent auto-bump conflicts.
The auto-bump logic contains confirmed critical and major issues:
-
Pre-release version handling: If
CURRENT_VERSIONcontains pre-release identifiers (e.g.,1.2.3-beta.1), the version parsing at lines 113 and 73 will fail silently. TheIFS='.'split assigns"3-beta"toPATCH, and bash arithmetic treats the non-numeric"3-beta"as 0, resulting in an incorrect version1.2.1instead of1.2.4-beta.1. The workflow supports pre-release versions viainputs.prerelease, making this a real vulnerability. -
Missing NEW_VERSION validation: After computing
NEW_VERSIONat line 114, there is no check to verify that tagv$NEW_VERSIONdoes not already exist. OnlyCURRENT_VERSIONis checked at line 110. -
Race condition with concurrent workflow_run: Multiple
workflow_runinstances triggered by rapid commits will both read the sameCURRENT_VERSIONfrom line 57 before the first job'sbump-versionstep completes, causing both to compute and attempt to push the identicalNEW_VERSION. Although the release job at line 441 skips tag creation if it exists, the check job has already outputshould_release=truefor both instances, creating an inconsistent state.
Add version format validation and NEW_VERSION tag existence check before computing the bump.
Problem
When the Release workflow is triggered by
workflow_run(after CI completes on main), it previously skipped the release if the current version tag already existed. This required manual version bumps before each release, which is what happened with PR #3.Solution
Now, when triggered by
workflow_run:Cargo.toml, then releaseHow It Works
Result
After this change, releases will be fully automatic after merging PRs to main:
workflow_runCargo.tomlNo more manual version bumps needed!
Pull Request opened by Augment Code with guidance from the PR author
Summary by CodeRabbit
Chores
✏️ Tip: You can customize this high-level summary in your review settings.