Skip to content

Commit 1742456

Browse files
committed
ci: use setup-cz
1 parent 2c5f187 commit 1742456

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed

.github/workflows/bumpversion.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,38 @@ jobs:
1010
if: ${{ github.repository == 'commitizen-tools/commitizen' && !startsWith(github.event.head_commit.message, 'bump:') }}
1111
runs-on: ubuntu-latest
1212
name: "Bump version and create changelog with commitizen"
13+
permissions:
14+
contents: write
15+
actions: write
1316
steps:
1417
- name: Check out
1518
uses: actions/checkout@v6
1619
with:
1720
fetch-depth: 0
18-
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
19-
- name: Create bump and changelog
20-
uses: commitizen-tools/commitizen-action@master
21-
with:
22-
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
23-
changelog_increment_filename: body.md
21+
fetch-tags: true
22+
- uses: commitizen-tools/setup-cz@main
23+
- id: bump-version
24+
run: |
25+
cz bump --yes
26+
git push --follow-tags
27+
new_version="$(cz version -p)"
28+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
29+
new_version_tag="$(cz version -p --tag)"
30+
echo "new_version_tag=$new_version_tag" >> $GITHUB_OUTPUT
31+
- name: Build changelog for Release
32+
env:
33+
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
34+
run: |
35+
cz changelog --dry-run "${NEW_VERSION}" > .changelog.md
2436
- name: Release
25-
uses: ncipollo/release-action@v1
26-
with:
27-
tag: v${{ env.REVISION }}
28-
bodyFile: "body.md"
29-
skipIfReleaseExists: true
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
NEW_VERSION_TAG: ${{ steps.bump-version.outputs.new_version_tag }}
40+
run: |
41+
gh release create "${NEW_VERSION_TAG}" --notes-file .changelog.md
42+
- name: trigger other workflow
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: |
46+
gh workflow run pythonpublish.yml \
47+
-f "version=${{ steps.bump-version.outputs.new_version_tag }}"

.github/workflows/pythonpublish.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
name: Upload Python Package
22

3+
# With the current configuration this workflow will be
4+
# triggered via `workflow_dispatch` in `bumpversion.yml`.
5+
# We leave the `push.tags` trigger to allow for manual releases
6+
# in case we need to bump locally, and we actively push the tag.
7+
# The PERSONAL_ACCESS_TOKEN is no longer needed as we use the OIDC token instead.
8+
# We favor this approach because it requires less steps to set up and is more secure.
39
on:
410
push:
511
tags:
612
- "v*"
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: "Version to trigger"
17+
required: true
718

819
jobs:
920
deploy:
@@ -15,8 +26,8 @@ jobs:
1526
steps:
1627
- uses: actions/checkout@v6
1728
with:
18-
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
1929
fetch-depth: 0
30+
ref: ${{ inputs.version || github.ref_name }}
2031
- name: Set up Python
2132
uses: astral-sh/setup-uv@v7
2233
- name: Build

docs/config/option.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Required if you use `version_provider = "commitizen"`.
2222
- Type: `str`
2323
- Default: `None`
2424

25-
Example: `"0.1.2"`.
25+
Example: `"0.1.2"`.
2626

2727
## `style`
2828

docs/tutorials/github_actions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This guide shows you how to automatically bump versions, create changelogs, and publish releases using Commitizen in GitHub Actions.
44

5+
!!! tip
6+
Check the new [setup-cz](https://github.com/marketplace/actions/setup-commitizen-cli) action, simple and with [examples](https://github.com/commitizen-tools/setup-cz/tree/main/examples)
7+
58
### Prerequisites
69

710
Before setting up the workflow, you'll need:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ version_files = [
144144
]
145145
version_provider = "uv"
146146
version_scheme = "pep440"
147-
147+
annotated_tag = true
148148

149149
[tool.uv.build-backend]
150150
module-name = "commitizen"

0 commit comments

Comments
 (0)