Skip to content

Commit e483556

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 3eada5d commit e483556

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/bumpversion.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,29 @@ 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-
cz bump --yes
41+
old_sha="$(git rev-parse HEAD)"
42+
cz bump --yes --no-raise 21
43+
44+
if [ "$(git rev-parse HEAD)" = "$old_sha" ]; then
45+
echo "No bump-eligible commits found, skipping release."
46+
echo "bumped=false" >> $GITHUB_OUTPUT
47+
exit 0
48+
fi
49+
50+
echo "bumped=true" >> $GITHUB_OUTPUT
4251
git push --follow-tags
4352
new_version="$(cz version -p)"
4453
echo "new_version=$new_version" >> $GITHUB_OUTPUT
4554
new_version_tag="$(cz version -p --tag)"
4655
echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT
4756
- name: Build changelog for Release
57+
if: steps.bump-version.outputs.bumped == 'true'
4858
env:
4959
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
5060
run: |
5161
cz changelog --dry-run "${NEW_VERSION}" > .changelog.md
5262
- name: Release
63+
if: steps.bump-version.outputs.bumped == 'true'
5364
env:
5465
GH_TOKEN: ${{ github.token }}
5566
NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}

0 commit comments

Comments
 (0)