Skip to content

Commit 3c9795d

Browse files
committed
feat: replace release-drafter with git-cliff and gh-cli
ref #47
1 parent 724d561 commit 3c9795d

File tree

8 files changed

+590
-116
lines changed

8 files changed

+590
-116
lines changed

.github/cliff.toml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
# template for the changelog header
6+
header = """
7+
# Changelog\n
8+
All notable changes to this project will be documented in this file.
9+
10+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
11+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12+
<!-- markdownlint-disable MD024 -->\n
13+
"""
14+
# template for the changelog body
15+
# https://keats.github.io/tera/docs/#introduction
16+
body = """
17+
{%- macro remote_url() -%}
18+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
19+
{%- endmacro -%}
20+
{%- set init_commit = get_env(name="FIRST_COMMIT", default="") -%}
21+
{%- set this_version = "Unreleased" -%}
22+
23+
{% if version -%}
24+
{%- set this_version = version | trim_start_matches(pat="v") -%}
25+
## [{{ this_version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
26+
{%- if message %}
27+
28+
> {{ message }}
29+
{%- endif %}
30+
{% else -%}
31+
## [Unreleased]
32+
{% endif -%}
33+
34+
{% for group, commits in commits | group_by(attribute="group") %}
35+
### {{ group | upper_first }}
36+
{% for commit in commits | unique(attribute="message") %}
37+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
38+
{% if commit.remote.username %} by \\@{{ commit.remote.username }}{%- endif -%}
39+
{% if commit.remote.pr_number %} in \
40+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})
41+
{%- else %} in \
42+
[`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }})
43+
{%- endif -%}
44+
{% endfor %}
45+
{% endfor -%}
46+
47+
{% set first_commit = previous.version -%}
48+
{%- set last_commit = "HEAD" -%}
49+
{% if version -%}
50+
{%- set last_commit = version -%}
51+
{%- if not previous.version -%}
52+
{%- set first_commit = init_commit -%}
53+
{%- endif -%}
54+
{%- endif %}
55+
[{{ this_version }}]: {{ self::remote_url() }}/compare/{{ first_commit }}...{{ last_commit }}
56+
57+
Full commit diff: [`{% if previous.version -%}
58+
{{ first_commit }}
59+
{%- else -%}
60+
{{ init_commit | truncate(length=7, end="") }}
61+
{%- endif %}...{{ last_commit }}`][{{ this_version }}]
62+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
63+
## New Contributors
64+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
65+
- @{{ contributor.username }} made their first contribution
66+
{%- if contributor.pr_number %} in \
67+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
68+
{%- endif %}
69+
{%- endfor %}
70+
{% endif %}
71+
72+
"""
73+
# template for the changelog footer
74+
footer = """
75+
<!-- generated by git-cliff -->
76+
"""
77+
# remove the leading and trailing whitespace from the templates
78+
trim = true
79+
# The file path for output. This can be overridden with `--output` CLI arg
80+
# output = "CHANGELOG.md"
81+
82+
[git]
83+
# parse the commits based on https://www.conventionalcommits.org
84+
conventional_commits = true
85+
# filter out the commits that are not conventional
86+
filter_unconventional = false
87+
# regex for preprocessing the commit messages
88+
commit_preprocessors = [
89+
# Remove the auto-appended PR numbers from commit titles.
90+
# For example, `some PR title (#42)` becomes `some PR title`
91+
# NOTE: git-cliff will append a link to the commit or PR in the commit title.
92+
# For example, `some PR title (#42)` gets displayed as
93+
# `some PR title by <user> in <link to #42>`
94+
{ pattern = '(?m)(\s?\(#[0-9]+\))$', replace = "" },
95+
]
96+
# regex for parsing and grouping commits
97+
commit_parsers = [
98+
# The order of parsers matters. Put rules for PR labels first to prioritize PR labels.
99+
{ field = "github.pr_labels", pattern = "breaking", group = "<!-- 0 --> 💥 Breaking changes" },
100+
{ field = "github.pr_labels", pattern = "breaking-change", group = "<!-- 0 --> 💥 Breaking changes" },
101+
{ field = "github.pr_labels", pattern = "feature", group = "<!-- 1 --> 🚀 New features and improvements" },
102+
{ field = "github.pr_labels", pattern = "enhancement", group = "<!-- 1 --> 🚀 New features and improvements" },
103+
{ field = "github.pr_labels", pattern = "deprecated", group = "<!-- 2 --> ⚠️ Deprecated" },
104+
{ field = "github.pr_labels", pattern = "removed", group = "<!-- 3 --> 🚨 Removed" },
105+
{ field = "github.pr_labels", pattern = "bug", group = "<!-- 4 --> 🐛 Bug fixes" },
106+
{ field = "github.pr_labels", pattern = "bugfix", group = "<!-- 4 --> 🐛 Bug fixes" },
107+
{ field = "github.pr_labels", pattern = "fix", group = "<!-- 4 --> 🐛 Bug fixes" },
108+
{ field = "github.pr_labels", pattern = "regression", group = "<!-- 4 --> 🐛 Bug fixes" },
109+
{ field = "github.pr_labels", pattern = "security", group = "<!-- 5 --> 🔐 Security" },
110+
{ field = "github.pr_labels", pattern = "dependencies", group = "<!-- 6 --> 📦 Dependency updates" },
111+
{ field = "github.pr_labels", pattern = "test", group = "<!-- 7 -->🚦 Tests"},
112+
{ field = "github.pr_labels", pattern = "tests", group = "<!-- 7 -->🚦 Tests"},
113+
{ field = "github.pr_labels", pattern = "localization", group = "<!-- 8 --> 🌐 Localization and translation"},
114+
{ field = "github.pr_labels", pattern = "documentation", group = "<!-- 9 --> 📝 Documentation" },
115+
{ field = "github.pr_labels", pattern = "chore", group = "<!-- 10 --> 👻 Maintenance" },
116+
{ field = "github.pr_labels", pattern = "maintenance", group = "<!-- 10 --> 👻 Maintenance" },
117+
{ field = "github.pr_labels", pattern = "internal", group = "<!-- 10 --> 👻 Maintenance" },
118+
{ field = "github.pr_labels", pattern = "developer", group = "<!-- 11 --> 👷 Changes for developers" },
119+
{ field = "github.pr_labels", pattern = "refactor", group = "<!-- 12 --> ✍ Other changes" },
120+
{ field = "github.pr_labels", pattern = "skip-changelog", skip = true },
121+
{ field = "github.pr_labels", pattern = "no-changelog", skip = true },
122+
{ field = "github.pr_labels", pattern = "invalid", skip = true },
123+
# Here are rules that apply to conventional commits
124+
{ field = "group", pattern = "add", group = "<!-- 1 --> 🚀 New features and improvements" },
125+
{ field = "group", pattern = "feat", group = "<!-- 1 --> 🚀 New features and improvements" },
126+
{ field = "group", pattern = "fix", group = "<!-- 4 --> 🐛 Bug fixes" },
127+
{ field = "group", pattern = "perf", group = "<!-- 4 --> 🐛 Bug fixes" },
128+
{ field = "group", pattern = "build", group = "<!-- 6 --> 📦 Dependency updates" },
129+
{ field = "group", pattern = "test", group = "<!-- 7 -->🚦 Tests" },
130+
{ field = "group", pattern = "docs", group = "<!-- 9 --> 📝 Documentation" },
131+
{ field = "group", pattern = "chore", group = "<!-- 10 --> 👻 Maintenance" },
132+
{ field = "group", pattern = "style", group = "<!-- 10 --> 👻 Maintenance" },
133+
{ field = "breaking", pattern = true, group = "<!-- 0 --> 💥 Breaking Changes" },
134+
{ field = "group", pattern = "remove", group = "<!-- 3 --> 🚨 Removed" },
135+
{ field = "group", pattern = "deprecate", group = "<!-- 2 --> ⚠️ Deprecated" },
136+
{ field = "group", pattern = "delete", group = "<!-- 3 --> 🚨 Removed" },
137+
{ field = "group", pattern = "security", group = "<!-- 5 --> 🔐 Security" },
138+
{ field = "group", pattern = "refactor", group = "<!-- 12 --> ✍ Other changes" },
139+
# Here are rules that apply to unconventional commits
140+
{ message = "^[a|A]dd", group = "<!-- 1 --> 🚀 New features and improvements" },
141+
{ message = "^[s|S]upport", group = "<!-- 1 --> 🚀 New features and improvements" },
142+
{ message = "^.*: support", group = "<!-- 1 --> 🚀 New features and improvements" },
143+
{ message = "^.*: add", group = "<!-- 1 --> 🚀 New features and improvements" },
144+
{ message = "^.*: deprecated", group = "<!-- 2 --> ⚠️ Deprecated" },
145+
{ message = "[d|D]eprecate", group = "<!-- 2 --> ⚠️ Deprecated" },
146+
{ message = "[t|T]ests", group = "<!-- 7 -->🚦 Tests"},
147+
{ message = "[r|R]emove", group = "<!-- 3 --> 🚨 Removed" },
148+
{ message = "^.*: remove", group = "<!-- 3 --> 🚨 Removed" },
149+
{ message = "^.*: delete", group = "<!-- 3 --> 🚨 Removed" },
150+
{ message = "^[f|F]ix", group = "<!-- 4 --> 🐛 Bug fixes" },
151+
{ message = "^.*: fix", group = "<!-- 4 --> 🐛 Bug fixes" },
152+
{ message = "^.*: secure", group = "<!-- 5 --> 🔐 Security" },
153+
{ message = "[s|S]ecure", group = "<!-- 5 --> 🔐 Security" },
154+
{ message = "[s|S]ecurity", group = "<!-- 5 --> 🔐 Security" },
155+
{ message = "^.*: security", group = "<!-- 5 --> 🔐 Security" },
156+
{ message = "doc", group = "<!-- 9 --> 📝 Documentation" },
157+
{ message = "docs", group = "<!-- 9 --> 📝 Documentation" },
158+
{ message = "documentation", group = "<!-- 9 --> 📝 Documentation" },
159+
{ message = "[r|R]efactor", group = "<!-- 9 --> 🗨️ Changed" },
160+
{ field = "github.pr_labels", pattern = ".*", group = "<!-- 9 --> 🗨️ Changed" },
161+
{ message = "^.*", group = "<!-- 9 --> 🗨️ Changed" },
162+
]
163+
# filter out the commits that are not matched by commit parsers
164+
filter_commits = true
165+
# sort the tags topologically
166+
topo_order = false
167+
# sort the commits inside sections by oldest/newest order
168+
sort_commits = "oldest"

.github/release-drafter.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
git-cliff==2.10.0

.github/workflows/release-drafter.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)