Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ jobs:
assert.ok(changelogContent.includes('### Fix'), 'Expected changelog to contain a header for fixes');
test-trigger-other-job:
runs-on: ubuntu-latest
# Skip when the token will be read-only and `gh workflow run` would
# fail with HTTP 403 ("Resource not accessible by integration"):
# - Fork PRs: GITHUB_TOKEN is always read-only on fork-originated PRs.
# - Dependabot PRs: even though the branch is in the same repo, the
# dependabot[bot] actor receives a restricted token by default.
if: >-
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v6
with:
Expand Down
17 changes: 16 additions & 1 deletion examples/bump-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,33 @@ jobs:
python-version: "3.x"
- id: bump-version
run: |
cz bump --yes --annotated-tag
old_sha="$(git rev-parse HEAD)"
# Pass `--no-raise 21` so that pushing only non-bump-eligible commits
# (e.g. docs:, ci:, build(deps):) does not fail the workflow. Note
# that `--no-raise` is a top-level option and must come before the
# `bump` subcommand. Exit code 21 is NO_COMMITS_TO_BUMP.
cz --no-raise 21 bump --yes --annotated-tag

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 }}
Expand Down
18 changes: 17 additions & 1 deletion examples/trigger-other-job/.github/workflows/bump-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ jobs:
- id: bump-version
run: |
old_version="$(cz version -p)"
cz bump --yes --annotated-tag
old_sha="$(git rev-parse HEAD)"
# Pass `--no-raise 21` so that pushing only non-bump-eligible commits
# (e.g. docs:, ci:, build(deps):) does not fail the workflow. Note
# that `--no-raise` is a top-level option and must come before the
# `bump` subcommand. Exit code 21 is NO_COMMITS_TO_BUMP.
cz --no-raise 21 bump --yes --annotated-tag

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)"
new_version_tag="$(cz version -p --tag)"
Expand All @@ -32,17 +45,20 @@ jobs:
echo "new_version=$new_version" >> $GITHUB_OUTPUT
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 }}
run: |
gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md
- name: trigger other workflow
if: steps.bump-version.outputs.bumped == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
Expand Down
Loading