Skip to content

Commit c5b1e5c

Browse files
KaboomFoxclaude
andcommitted
Add automated changelog generation with git-cliff
Introduces cliff.toml with custom commit parsers for the project's verb-first commit style, and updates the release workflow to generate CHANGELOG.md and use it for GitHub Release notes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e53a943 commit c5b1e5c

File tree

2 files changed

+103
-3
lines changed

2 files changed

+103
-3
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,48 @@ jobs:
1313
name: CI
1414
uses: ./.github/workflows/ci.yml
1515

16+
changelog:
17+
name: Generate changelog
18+
needs: ci
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
outputs:
23+
release_body: ${{ steps.release_body.outputs.content }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: main
28+
fetch-depth: 0
29+
30+
- name: Generate full changelog
31+
uses: orhun/git-cliff-action@v4
32+
with:
33+
args: --tag ${{ github.ref_name }}
34+
env:
35+
OUTPUT: CHANGELOG.md
36+
GITHUB_TOKEN: ${{ github.token }}
37+
38+
- name: Generate release body
39+
id: release_body
40+
uses: orhun/git-cliff-action@v4
41+
with:
42+
args: --latest --tag ${{ github.ref_name }} --strip header
43+
env:
44+
GITHUB_TOKEN: ${{ github.token }}
45+
46+
- name: Commit changelog
47+
run: |
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
git add CHANGELOG.md
51+
git diff --staged --quiet && exit 0
52+
git commit -m "Update CHANGELOG.md for ${{ github.ref_name }} [skip ci]"
53+
git push origin main
54+
1655
publish:
1756
name: Publish to crates.io
18-
needs: ci
57+
needs: changelog
1958
runs-on: ubuntu-latest
2059
steps:
2160
- uses: actions/checkout@v4
@@ -30,14 +69,15 @@ jobs:
3069

3170
github-release:
3271
name: GitHub Release
33-
needs: publish
72+
needs: [changelog, publish]
3473
runs-on: ubuntu-latest
3574
permissions:
3675
contents: write
3776
steps:
3877
- uses: actions/checkout@v4
3978

4079
- name: Create GitHub Release
41-
run: gh release create "${{ github.ref_name }}" --generate-notes
80+
run: gh release create "${{ github.ref_name }}" --notes "$RELEASE_BODY"
4281
env:
4382
GH_TOKEN: ${{ github.token }}
83+
RELEASE_BODY: ${{ needs.changelog.outputs.release_body }}

cliff.toml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[changelog]
2+
header = """# Changelog
3+
4+
All notable changes to this project will be documented in this file.
5+
6+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
8+
"""
9+
body = """
10+
{%- macro remote_url() -%}
11+
https://github.com/KaboomFox/ws-shard-manager
12+
{%- endmacro -%}
13+
14+
{% if version -%}
15+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
16+
{% else -%}
17+
## [Unreleased]
18+
{% endif -%}
19+
20+
{% for group, commits in commits | group_by(attribute="group") %}
21+
### {{ group | striptags | trim }}
22+
{% for commit in commits %}
23+
- {{ commit.message | split(pat="\n") | first | trim }}
24+
{%- endfor %}
25+
{% endfor %}
26+
"""
27+
footer = """
28+
{%- macro remote_url() -%}
29+
https://github.com/KaboomFox/ws-shard-manager
30+
{%- endmacro -%}
31+
32+
{% for release in releases -%}
33+
{% if release.version -%}
34+
{% if release.previous.version -%}
35+
[{{ release.version | trim_start_matches(pat="v") }}]: {{ self::remote_url() }}/compare/{{ release.previous.version }}...{{ release.version }}
36+
{% else -%}
37+
[{{ release.version | trim_start_matches(pat="v") }}]: {{ self::remote_url() }}/releases/tag/{{ release.version }}
38+
{% endif -%}
39+
{% else -%}
40+
{% if release.previous.version -%}
41+
[Unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}...HEAD
42+
{% endif -%}
43+
{% endif -%}
44+
{% endfor %}
45+
"""
46+
trim = true
47+
48+
[git]
49+
conventional_commits = false
50+
commit_parsers = [
51+
{ message = "^Bump version", skip = true },
52+
{ message = "^Add|^Initial|^Support", group = "Added" },
53+
{ message = "^Fix", group = "Fixed" },
54+
{ message = "^Document", group = "Documentation" },
55+
{ message = "^Remove", group = "Removed" },
56+
{ message = "^Sanitize", group = "Security" },
57+
{ message = "^Revert", group = "Reverted" },
58+
{ message = "^Improve|^Update|^Relax|^Reduce|^Refactor|^Major", group = "Changed" },
59+
{ message = ".*", group = "Changed" },
60+
]

0 commit comments

Comments
 (0)