Skip to content

Commit ca48e4b

Browse files
ci(bump): gracefully handle no bump-eligible commits
When commits like docs:, ci:, or build(deps): are pushed to master, cz bump exits with code 21 (NO_COMMITS_TO_BUMP), failing the workflow. Handle exit code 21 explicitly by setting bumped=false and exiting 0. Subsequent changelog and release steps are now conditional on bumped == 'true', so they are skipped when there is nothing to release. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9d80891 commit ca48e4b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/bumpversion.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,33 @@ jobs:
3838
git-user-email: "${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
3939
- id: bump-version
4040
run: |
41+
set +e
4142
cz bump --yes
43+
exit_code=$?
44+
set -e
45+
46+
if [ $exit_code -eq 21 ]; then
47+
echo "No bump-eligible commits found, skipping release."
48+
echo "bumped=false" >> $GITHUB_OUTPUT
49+
exit 0
50+
elif [ $exit_code -ne 0 ]; then
51+
exit $exit_code
52+
fi
53+
54+
echo "bumped=true" >> $GITHUB_OUTPUT
4255
git push --follow-tags
4356
new_version="$(cz version -p)"
4457
echo "new_version=$new_version" >> $GITHUB_OUTPUT
4558
new_version_tag="$(cz version -p --tag)"
4659
echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT
4760
- name: Build changelog for Release
61+
if: steps.bump-version.outputs.bumped == 'true'
4862
env:
4963
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
5064
run: |
5165
cz changelog --dry-run "${NEW_VERSION}" > .changelog.md
5266
- name: Release
67+
if: steps.bump-version.outputs.bumped == 'true'
5368
env:
5469
GH_TOKEN: ${{ github.token }}
5570
NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}

0 commit comments

Comments
 (0)