Skip to content

Commit 7d38812

Browse files
authored
fix: correct version bump detection logic in GitHub Actions workflow (#22)
- Fix conditional logic that incorrectly detected version bump requirements - Change from exit code checking to output pattern matching for cz bump --dry-run - Improve error handling with proper stderr capture (2>&1) - Add clearer logging messages for version bump decisions - Handle changelog generation failures gracefully The previous logic failed because cz bump --dry-run returns non-zero exit code even when version bump is needed, due to changelog generation errors. Now we check for 'bump: version' pattern in output instead of exit code. Fixes the issue where workflow showed 'No version bump needed' while actually detecting version changes (e.g., 0.2.0 → 0.2.1 PATCH increment).
1 parent 4bde247 commit 7d38812

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,27 @@ jobs:
6767
run: |
6868
# Git-tag-based versioning: Version is determined entirely by git tags
6969
# No pyproject.toml version updates needed - everything is tag-driven
70-
if cz bump --dry-run 2>/dev/null; then
70+
71+
# Check if there are commits that warrant a version bump
72+
DRY_RUN_OUTPUT=$(cz bump --dry-run 2>&1)
73+
if echo "$DRY_RUN_OUTPUT" | grep -q "bump: version"; then
7174
echo "bump_needed=true" >> $GITHUB_OUTPUT
75+
echo "Version bump detected based on conventional commits"
7276
7377
# Get the new version that commitizen would create based on conventional commits
74-
NEW_VERSION=$(cz bump --dry-run | grep "bump: version" | sed 's/.*→ //')
78+
NEW_VERSION=$(echo "$DRY_RUN_OUTPUT" | grep "bump: version" | sed 's/.*→ //')
7579
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
80+
echo "New version will be: $NEW_VERSION"
7681
7782
# Generate changelog content from last tag to current commits
78-
CHANGELOG_CONTENT=$(cz changelog --unreleased-version=$NEW_VERSION --dry-run)
83+
CHANGELOG_CONTENT=$(cz changelog --unreleased-version=$NEW_VERSION --dry-run 2>/dev/null || echo "Changelog generation failed")
7984
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
8085
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
8186
echo "EOF" >> $GITHUB_OUTPUT
8287
8388
# Create ONLY git tag - no file modifications needed
8489
# All version info comes from git tags via dynamic version detection
90+
echo "Creating git tag..."
8591
cz bump --yes
8692
8793
# Push based on branch protection status

0 commit comments

Comments
 (0)