Skip to content

Commit f3a8404

Browse files
bearomorphismCopilot
authored andcommitted
docs(examples): gracefully handle no bump-eligible commits
Update both bump-release.yaml examples so that pushing only commits which do not trigger a version bump (e.g. docs:, ci:, build(deps):) does not fail the workflow with exit code 21. The bump step now passes `--no-raise 21` to cz bump and detects whether HEAD changed; if not, it sets `bumped=false` and exits 0. Subsequent steps (changelog, release, trigger-other-workflow) are guarded by `steps.bump-version.outputs.bumped == 'true'` so they are skipped on no-op runs. This mirrors the same pattern already used in commitizen's own bumpversion.yml workflow (see commitizen-tools/commitizen#1950). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7247d00 commit f3a8404

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎examples/bump-release.yaml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,31 @@ jobs:
2222
python-version: "3.x"
2323
- id: bump-version
2424
run: |
25-
cz bump --yes --annotated-tag
25+
old_sha="$(git rev-parse HEAD)"
26+
# Pass --no-raise 21 so that pushing only non-bump-eligible commits
27+
# (e.g. docs:, ci:, build(deps):) does not fail the workflow.
28+
cz bump --yes --annotated-tag --no-raise 21
29+
30+
if [ "$(git rev-parse HEAD)" = "$old_sha" ]; then
31+
echo "No bump-eligible commits found, skipping release."
32+
echo "bumped=false" >> $GITHUB_OUTPUT
33+
exit 0
34+
fi
35+
36+
echo "bumped=true" >> $GITHUB_OUTPUT
2637
git push --follow-tags
2738
new_version="$(cz version -p)"
2839
echo "new_version=$new_version" >> $GITHUB_OUTPUT
2940
new_version_tag="$(cz version -p --tag)"
3041
echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT
3142
- name: Build changelog for Release
43+
if: steps.bump-version.outputs.bumped == 'true'
3244
env:
3345
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
3446
run: |
3547
cz changelog --dry-run "${NEW_VERSION}" > .changelog.md
3648
- name: Release
49+
if: steps.bump-version.outputs.bumped == 'true'
3750
env:
3851
GH_TOKEN: ${{ github.token }}
3952
NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}

‎examples/trigger-other-job/.github/workflows/bump-release.yaml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ jobs:
2323
- id: bump-version
2424
run: |
2525
old_version="$(cz version -p)"
26-
cz bump --yes --annotated-tag
26+
old_sha="$(git rev-parse HEAD)"
27+
# Pass --no-raise 21 so that pushing only non-bump-eligible commits
28+
# (e.g. docs:, ci:, build(deps):) does not fail the workflow.
29+
cz bump --yes --annotated-tag --no-raise 21
30+
31+
if [ "$(git rev-parse HEAD)" = "$old_sha" ]; then
32+
echo "No bump-eligible commits found, skipping release."
33+
echo "bumped=false" >> $GITHUB_OUTPUT
34+
exit 0
35+
fi
36+
37+
echo "bumped=true" >> $GITHUB_OUTPUT
2738
git push --follow-tags
2839
new_version="$(cz version -p)"
2940
new_version_tag="$(cz version -p --tag)"
@@ -32,17 +43,20 @@ jobs:
3243
echo "new_version=$new_version" >> $GITHUB_OUTPUT
3344
echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT
3445
- name: Build changelog for Release
46+
if: steps.bump-version.outputs.bumped == 'true'
3547
env:
3648
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
3749
run: |
3850
cz changelog --dry-run "${NEW_VERSION}" > .changelog.md
3951
- name: Release
52+
if: steps.bump-version.outputs.bumped == 'true'
4053
env:
4154
GH_TOKEN: ${{ github.token }}
4255
NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}
4356
run: |
4457
gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md
4558
- name: trigger other workflow
59+
if: steps.bump-version.outputs.bumped == 'true'
4660
env:
4761
GH_TOKEN: ${{ github.token }}
4862
run: |

0 commit comments

Comments
 (0)