Skip to content

Commit 6f588ef

Browse files
Use git-cliff for changelog
1 parent bb0254a commit 6f588ef

File tree

2 files changed

+101
-4
lines changed

2 files changed

+101
-4
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- uses: actions/checkout@v5
2424
with:
2525
token: ${{ secrets.GITHUB_TOKEN }}
26+
fetch-depth: 0
2627
- name: Setup node
2728
uses: actions/setup-node@v4
2829
with:
@@ -35,8 +36,6 @@ jobs:
3536
targets: x86_64-unknown-linux-gnu
3637
- name: Install dependencies
3738
run: yarn install
38-
- name: Install conventional-changelog-cli
39-
run: npm install -g conventional-changelog-cli
4039
- name: Install cargo tools for license verification
4140
run: |
4241
cargo install --locked --version 0.8.2 cargo-about
@@ -50,8 +49,13 @@ jobs:
5049
run: |
5150
cargo about generate about.hbs > LICENSE-3RD-PARTY.txt
5251
- name: Generate changelog
53-
run: |
54-
conventional-changelog -p conventionalcommits -i CHANGELOG.md -s
52+
uses: orhun/git-cliff-action@v4
53+
with:
54+
config: cliff.toml
55+
args: --verbose
56+
env:
57+
OUTPUT: CHANGELOG.md
58+
GITHUB_REPO: ${{ github.repository }}
5559
- name: Build to update generated files
5660
run: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
5761
- name: Commit version changes

cliff.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
5+
[changelog]
6+
# A Tera template to be rendered for each release in the changelog.
7+
# See https://keats.github.io/tera/docs/#introduction
8+
body = """
9+
{% if version %}\
10+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
11+
{% else %}\
12+
## [unreleased]
13+
{% endif %}\
14+
{% for group, commits in commits | group_by(attribute="group") %}
15+
### {{ group | striptags | trim | upper_first }}
16+
{% for commit in commits %}
17+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
18+
{% if commit.breaking %}[**breaking**] {% endif %}\
19+
{{ commit.message | upper_first }}\
20+
{% endfor %}
21+
{% endfor %}
22+
"""
23+
# Remove leading and trailing whitespaces from the changelog's body.
24+
trim = true
25+
# Render body even when there are no releases to process.
26+
render_always = true
27+
# An array of regex based postprocessors to modify the changelog.
28+
postprocessors = [
29+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/$GITHUB_REPO/issues/${2}))" },
30+
]
31+
# render body even when there are no releases to process
32+
# render_always = true
33+
# output file path
34+
# output = "test.md"
35+
36+
[git]
37+
# Parse commits according to the conventional commits specification.
38+
# See https://www.conventionalcommits.org
39+
conventional_commits = true
40+
# Exclude commits that do not match the conventional commits specification.
41+
filter_unconventional = true
42+
# Require all commits to be conventional.
43+
# Takes precedence over filter_unconventional.
44+
require_conventional = false
45+
# Split commits on newlines, treating each line as an individual commit.
46+
split_commits = false
47+
# An array of regex based parsers to modify commit messages prior to further processing.
48+
commit_preprocessors = [
49+
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
50+
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
51+
# Check spelling of the commit message using https://github.com/crate-ci/typos.
52+
# If the spelling is incorrect, it will be fixed automatically.
53+
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
54+
]
55+
# Prevent commits that are breaking from being excluded by commit parsers.
56+
protect_breaking_commits = false
57+
# An array of regex based parsers for extracting data from the commit message.
58+
# Assigns commits to groups.
59+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
60+
commit_parsers = [
61+
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
62+
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
63+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
64+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
65+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
66+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
67+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
68+
{ message = "^chore\\(release\\): prepare for", skip = true },
69+
{ message = "^chore\\(deps.*\\)", skip = true },
70+
{ message = "^chore\\(pr\\)", skip = true },
71+
{ message = "^chore\\(pull\\)", skip = true },
72+
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
73+
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
74+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
75+
{ message = ".*", group = "<!-- 10 -->💼 Other" },
76+
]
77+
# Exclude commits that are not matched by any commit parser.
78+
filter_commits = false
79+
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
80+
link_parsers = [
81+
{ pattern = "#(\\d+)", href = "https://github.com/$GITHUB_REPO/issues/$1" }
82+
]
83+
# Include only the tags that belong to the current branch.
84+
use_branch_tags = false
85+
# Order releases topologically instead of chronologically.
86+
topo_order = false
87+
# Order releases topologically instead of chronologically.
88+
topo_order_commits = true
89+
# Order of commits in each group/release within the changelog.
90+
# Allowed values: newest, oldest
91+
sort_commits = "oldest"
92+
# Process submodules commits
93+
recurse_submodules = false

0 commit comments

Comments
 (0)