Skip to content

Commit f629d1e

Browse files
committed
ci: use setup-cz
1 parent d822e4e commit f629d1e

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
push:
55
tags:
66
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to trigger"
11+
required: true
712

813
jobs:
914
deploy:
@@ -15,8 +20,8 @@ jobs:
1520
steps:
1621
- uses: actions/checkout@v6
1722
with:
18-
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
1923
fetch-depth: 0
24+
ref: ${{ inputs.version || github.ref_name }}
2025
- name: Set up Python
2126
uses: astral-sh/setup-uv@v7
2227
- name: Build

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)