Skip to content

Commit 11f459a

Browse files
authored
fix: resolve GitHub Actions workflow version detection and error handling issues (#23)
* fix: correct version bump detection logic in GitHub Actions workflow - 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). * fix: add comprehensive error handling and debugging for commitizen workflow - Add fallback manual tag creation when commitizen bump fails - Include detailed debugging information for CI environment - Display commitizen config, git status, tags, and recent commits - Improve error handling with graceful fallbacks - Add informative logging with emoji indicators for better readability This should resolve the 'exit code 16' errors by providing alternative tag creation methods and better visibility into CI environment state. * fix: improve error handling for commitizen dry-run failures - Add conditional error handling for cz bump --dry-run - Use 'true' fallback to prevent script exit on commitizen errors - Better logging of exit codes and error conditions - Ensure version detection continues even if commitizen returns non-zero This should prevent the workflow from failing due to commitizen exit code 16 while still capturing and processing the version bump information. * fix: add tag existence check to prevent duplicate tag errors - Check if tag already exists before manual creation - Graceful handling when target tag already present - Prevent 'tag already exists' fatal errors - Better logging for tag creation status This resolves the 'fatal: tag already exists' error that occurs when attempting to create tags that were previously created. * fix: test version bump calculation from 0.2.0 baseline This commit should trigger a PATCH version bump from 0.2.0 → 0.2.1 * chore: remove test file used for version bump validation --------- Signed-off-by: 拐爷&&老拐瘦 <[email protected]>
1 parent 7d38812 commit 11f459a

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,32 @@ jobs:
6969
# No pyproject.toml version updates needed - everything is tag-driven
7070
7171
# Check if there are commits that warrant a version bump
72-
DRY_RUN_OUTPUT=$(cz bump --dry-run 2>&1)
72+
73+
echo "🔍 Checking for conventional commits that warrant version bump..."
74+
echo "📋 Current commitizen config:"
75+
cz info || echo "⚠️ Commitizen info failed"
76+
77+
echo "📊 Current git status:"
78+
git status --porcelain
79+
80+
echo "🏷️ Current tags:"
81+
git tag -l --sort=-version:refname | head -5
82+
83+
echo "📝 Recent commits:"
84+
git log --oneline -5
85+
86+
# Try commitizen dry-run with error handling
87+
if DRY_RUN_OUTPUT=$(cz bump --dry-run 2>&1); then
88+
echo "🧪 Commitizen dry-run output:"
89+
echo "$DRY_RUN_OUTPUT"
90+
else
91+
echo "⚠️ Commitizen dry-run failed with exit code $?, trying alternative detection..."
92+
DRY_RUN_OUTPUT=$(cz bump --dry-run 2>&1 || true)
93+
echo "🧪 Commitizen dry-run output (with errors):"
94+
echo "$DRY_RUN_OUTPUT"
95+
fi
96+
97+
7398
if echo "$DRY_RUN_OUTPUT" | grep -q "bump: version"; then
7499
echo "bump_needed=true" >> $GITHUB_OUTPUT
75100
echo "Version bump detected based on conventional commits"
@@ -88,7 +113,23 @@ jobs:
88113
# Create ONLY git tag - no file modifications needed
89114
# All version info comes from git tags via dynamic version detection
90115
echo "Creating git tag..."
91-
cz bump --yes
116+
117+
118+
# Try commitizen bump with error handling
119+
if ! cz bump --yes; then
120+
echo "⚠️ Commitizen bump failed, trying manual tag creation..."
121+
122+
# Manual tag creation as fallback
123+
if git tag -l | grep -q "^v$NEW_VERSION$"; then
124+
echo "⚠️ Tag v$NEW_VERSION already exists, skipping tag creation"
125+
else
126+
git tag "v$NEW_VERSION" -m "bump: version $(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0') → $NEW_VERSION"
127+
echo "✅ Manual tag created: v$NEW_VERSION"
128+
fi
129+
else
130+
echo "✅ Commitizen tag created successfully"
131+
fi
132+
92133
93134
# Push based on branch protection status
94135
if [ "${{ steps.branch-protection.outputs.can_push_directly }}" = "true" ]; then

0 commit comments

Comments
 (0)