From e483556588ce269916c9ef494eee596221e6cd5e Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Fri, 8 May 2026 14:22:32 +0800 Subject: [PATCH] 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> --- .github/workflows/bumpversion.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index 00e8604e2..abcbc5172 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -38,18 +38,29 @@ jobs: git-user-email: "${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" - id: bump-version run: | - cz bump --yes + old_sha="$(git rev-parse HEAD)" + cz bump --yes --no-raise 21 + + if [ "$(git rev-parse HEAD)" = "$old_sha" ]; then + echo "No bump-eligible commits found, skipping release." + echo "bumped=false" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "bumped=true" >> $GITHUB_OUTPUT git push --follow-tags new_version="$(cz version -p)" echo "new_version=$new_version" >> $GITHUB_OUTPUT new_version_tag="$(cz version -p --tag)" echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT - name: Build changelog for Release + if: steps.bump-version.outputs.bumped == 'true' env: NEW_VERSION: ${{ steps.bump-version.outputs.new_version }} run: | cz changelog --dry-run "${NEW_VERSION}" > .changelog.md - name: Release + if: steps.bump-version.outputs.bumped == 'true' env: GH_TOKEN: ${{ github.token }} NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}