Skip to content

Commit 4e3d1dd

Browse files
committed
docs(gh): update gh action tutorial
1 parent 2f86834 commit 4e3d1dd

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

‎docs/tutorials/github_actions.md‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,49 @@ To automatically execute `cz bump` in your CI and push the new commit and tag ba
3838

3939
#### Step 3: Create the workflow file
4040

41-
Create a new file `.github/workflows/bumpversion.yml` in your repository with the following content:
41+
Create a new file `.github/workflows/bump-version.yml` in your repository with the following content:
4242

43-
```yaml title=".github/workflows/bumpversion.yml"
43+
```yaml title=".github/workflows/bump-version.yml"
4444
name: Bump version
4545

4646
on:
4747
push:
4848
branches:
49-
- master # or 'main' if that's your default branch
49+
- main
5050

5151
jobs:
52-
bump-version:
53-
if: "!startsWith(github.event.head_commit.message, 'bump:')"
52+
bump:
5453
runs-on: ubuntu-latest
55-
name: "Bump version and create changelog with commitizen"
54+
permissions:
55+
contents: write
56+
actions: write
5657
steps:
57-
- name: Check out
58-
uses: actions/checkout@v6
58+
- uses: actions/checkout@v7
5959
with:
6060
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
6161
fetch-depth: 0
62-
- name: Create bump and changelog
63-
uses: commitizen-tools/commitizen-action@master
62+
fetch-tags: true
63+
- uses: commitizen-tools/setup-cz@main
6464
with:
65-
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
65+
python-version: "3.x"
66+
- id: bump-version
67+
run: |
68+
cz bump --yes --annotated-tag
69+
git push --follow-tags
6670
```
6771
6872
#### How it works
6973
70-
- **Trigger**: The workflow runs on every push to the `master` branch (or `main` if you change it)
71-
- **Conditional check**: The `if` condition prevents infinite loops by skipping the job if the commit message starts with `bump:`
72-
- **Checkout**: Uses your personal access token to check out the repository with full history (`fetch-depth: 0`)
73-
- **Bump**: The `commitizen-action` automatically:
74+
- **Trigger**: The workflow runs on every push to the `main` branch (or `master` if that's your default branch)
75+
- **Permissions**: The job requests `contents: write` and `actions: write` so it can push the bump commit and tag, and trigger dependent workflows
76+
- **Checkout**: Uses your personal access token to check out the repository with full history (`fetch-depth: 0`) and all tags (`fetch-tags: true`)
77+
- **Setup**: The `setup-cz` action installs the Commitizen CLI with the requested Python version
78+
- **Bump**: The `cz bump --yes --annotated-tag` command automatically:
7479
- Determines the version increment based on your commit messages
7580
- Updates version files (as configured in your `pyproject.toml` or other config)
76-
- Creates a new git tag
81+
- Creates a new annotated git tag
7782
- Generates/updates the changelog
78-
- Pushes the commit and tag back to the repository
83+
- **Push**: `git push --follow-tags` pushes the bump commit along with the new tag back to the repository
7984

8085
Once you push this workflow file to your repository, it will automatically run on the next push to your default branch.
8186

0 commit comments

Comments
 (0)