You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7f03ff6
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -12,11 +12,11 @@ Before setting up the workflow, you'll need:
12
12
1. A personal access token with repository write permissions
13
13
2. Commitizen configured in your project (see [configuration documentation](../config/configuration_file.md))
14
14
15
-
### Automatic version bumping
15
+
### Automatic Version Bumping
16
16
17
17
To automatically execute `cz bump` in your CI and push the new commit and tag back to your repository, follow these steps:
18
18
19
-
#### Step 1: Create a personal access token
19
+
#### Step 1: Create a Personal Access Token
20
20
21
21
1. Go to [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens)
22
22
2. Click "Generate new token (classic)"
@@ -27,7 +27,7 @@ To automatically execute `cz bump` in your CI and push the new commit and tag ba
27
27
!!! warning "Important: Use Personal Access Token, not GITHUB_TOKEN"
28
28
If you use `GITHUB_TOKEN` instead of `PERSONAL_ACCESS_TOKEN`, the workflow won't trigger another workflow run. This is a GitHub security feature to prevent infinite loops. The `GITHUB_TOKEN` is treated like using `[skip ci]` in other CI systems.
29
29
30
-
#### Step 2: Add the token as a repository secret
30
+
#### Step 2: Add the Token as a Repository Secret
31
31
32
32
1. Go to your repository on GitHub
33
33
2. Navigate to `Settings > Secrets and variables > Actions`
@@ -36,97 +36,82 @@ To automatically execute `cz bump` in your CI and push the new commit and tag ba
36
36
5. Paste the token you copied in Step 1
37
37
6. Click "Add secret"
38
38
39
-
#### Step 3: Create the workflow file
39
+
#### Step 3: Create the Workflow File
40
40
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:
- **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:
96
+
- The action will trigger the workflow on every push to the `main` branch.
97
+
- The job requests `contents: write` and `actions: write` so it can push the bump commit and tag, and trigger dependent workflows.
98
+
- **Setup**: The `setup-cz` action installs the Commitizen CLI with the requested Python version
99
+
- **Bump**: The `cz bump --yes --annotated-tag` command automatically:
74
100
- Determines the version increment based on your commit messages
75
101
- Updates version files (as configured in your `pyproject.toml` or other config)
76
-
- Creates a new git tag
102
+
- Creates a new annotated git tag
77
103
- Generates/updates the changelog
78
-
- Pushes the commit and tag back to the repository
104
+
- **Push**: `git push --follow-tags` pushes the bump commit along with the new tag back to the repository
105
+
- **Github Release**: creates a Github Release
79
106
80
107
Once you push this workflow file to your repository, it will automatically run on the next push to your default branch.
81
108
82
-
Check out [commitizen-action](https://github.com/commitizen-tools/commitizen-action) for more details.
83
-
84
-
### Creating a GitHub release
85
-
86
-
To automatically create a GitHub release when a new version is bumped, you can extend the workflow above.
109
+
Check out [commitizen-tools/setup-cz](https://github.com/commitizen-tools/setup-cz) for more details.
87
110
88
-
The `commitizen-action` creates an environment variable called `REVISION` containing the newly created version. You can use this to create a release with the changelog content.
89
-
90
-
```yaml title=".github/workflows/bumpversion.yml"
91
-
name: Bump version
92
-
93
-
on:
94
-
push:
95
-
branches:
96
-
- master # or 'main' if that's your default branch
You can find the complete workflow in our repository at [bumpversion.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/bumpversion.yml).
125
-
126
-
### Previewing the version bump on pull requests
111
+
### Previewing the Version Bump on Pull Requests
127
112
128
113
To help reviewers spot unexpected version bumps before merging, you can run
129
-
`cz bump --dry-run`on every pull request and post (or update) a sticky
114
+
`cz version -p`on every pull request and post (or update) a sticky
130
115
comment summarizing the would-be version bump.
131
116
132
117
Create `.github/workflows/pr-bump-preview.yml`:
@@ -153,21 +138,20 @@ jobs:
153
138
}}
154
139
runs-on: ubuntu-latest
155
140
steps:
156
-
- name: Check out PR head
157
-
uses: actions/checkout@v6
141
+
- uses: actions/checkout@v7
158
142
with:
159
-
ref: ${{ github.event.pull_request.head.sha }}
160
143
fetch-depth: 0
161
144
fetch-tags: true
162
145
persist-credentials: false
163
146
- uses: commitizen-tools/setup-cz@main
164
147
with:
148
+
python-version: "3.x"
165
149
set-git-config: false
166
-
- name: Run cz bump --dry-run
150
+
- name: Run cz version
167
151
id: dry-run
168
152
run: |
169
153
set +e
170
-
output="$(cz bump --dry-run --yes 2>&1)"
154
+
output="$(cz version -p --next 2>&1)"
171
155
status=$?
172
156
set -e
173
157
{
@@ -222,40 +206,9 @@ jobs:
222
206
edit-mode: replace
223
207
```
224
208
225
-
#### How it works
226
-
227
-
- **Trigger**: `pull_request_target` runs in the context of the base
228
-
repository, which gives the workflow `pull-requests: write` permission
229
-
even for PRs from forks. We deliberately gate the job to **same-repo PRs
230
-
only** (`head.repo == base.repo`); fork PRs are skipped. This is because
231
-
`cz bump`renders [Jinja templates from the working directory][jinja]
232
-
whenever [`update_changelog_on_bump`](../config/configuration_file.md) is
233
-
enabled, and the renderer is not sandboxed — running it against
234
-
fork-controlled files under a write token would risk arbitrary code
235
-
execution and token exfiltration. Same-repo PRs are written by
236
-
collaborators who already have push access, so the same risk doesn't
You can find the complete workflow in our repository at [pr-bump-preview.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/pr-bump-preview.yml).
257
210
258
-
### Publishing a Python package
211
+
### Publishing a Python Package
259
212
260
213
After a new version tag is created by the bump workflow, you can automatically publish your package to PyPI.
261
214
@@ -280,7 +233,7 @@ After a new version tag is created by the bump workflow, you can automatically p
280
233
5. Paste the PyPI token
281
234
6. Click "Add secret"
282
235
283
-
#### Step 3: Create the publish workflow
236
+
#### Step 3: Create the Publish Workflow
284
237
285
238
Create a new file `.github/workflows/pythonpublish.yml` that triggers on tag pushes:
This workflow uses Poetry to build and publish the package. You can find the complete workflow in our repository at [pythonpublish.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/pythonpublish.yml).
267
+
This workflow uses uv to build and publish the package.
268
+
You can find the complete workflow in our repository at [pythonpublish.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/pythonpublish.yml).
324
269
325
270
!!! note "Alternative publishing methods"
326
271
You can also use [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) or other build tools like `setuptools`, `flit`, or `hatchling` to publish your package.
0 commit comments