Skip to content

Commit 238003f

Browse files
committed
feat: Create changelog for GH releases
1 parent e31da8f commit 238003f

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,27 @@ jobs:
1212
upload_url: ${{ steps.create_release.outputs.upload_url }}
1313
version: ${{ steps.get_version.outputs.version }}
1414
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
1519
- name: Get version from tag
1620
id: get_version
1721
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
1822

23+
- name: Install git-cliff
24+
uses: orhun/git-cliff-action@v2
25+
with:
26+
config: cliff.toml
27+
args: --current --strip header
28+
29+
- name: Generate changelog
30+
id: changelog
31+
run: |
32+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
33+
git-cliff --current --strip header >> $GITHUB_OUTPUT
34+
echo "EOF" >> $GITHUB_OUTPUT
35+
1936
- name: Create Release
2037
id: create_release
2138
uses: actions/create-release@v1
@@ -24,6 +41,9 @@ jobs:
2441
with:
2542
tag_name: ${{ github.ref }}
2643
release_name: Release ${{ github.ref_name }}
44+
body: |
45+
## Changelog
46+
${{ steps.changelog.outputs.changelog }}
2747
draft: false
2848
prerelease: false
2949

cliff.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[changelog]
2+
header = """
3+
# Changelog
4+
All notable changes to this project will be documented in this file.
5+
"""
6+
7+
body = """
8+
{% if version %}## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}{% else %}## [unreleased]{% endif %}
9+
10+
{% for group, commits in commits | group_by(attribute="group") %}
11+
### {{ group | upper_first }}
12+
{% for commit in commits %}
13+
* {% if commit.breaking %}**Breaking:** {% endif %}{{ commit.message | upper_first }}{% if commit.id %} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})){% endif %}
14+
{% endfor %}
15+
{% endfor %}\n
16+
"""
17+
18+
trim = true
19+
footer = ""
20+
21+
[git]
22+
conventional_commits = true
23+
filter_unconventional = true
24+
commit_parsers = [
25+
{ message = "^feat", group = "Features" },
26+
{ message = "^fix", group = "Bug Fixes" },
27+
{ message = "^docs", group = "Documentation" },
28+
{ message = "^perf", group = "Performance" },
29+
{ message = "^refactor", group = "Refactor" },
30+
{ message = "^style", group = "Styling" },
31+
{ message = "^test", group = "Testing" },
32+
{ message = "^chore\\(release\\): prepare for", skip = true },
33+
{ message = "^chore", group = "Miscellaneous Tasks" },
34+
]
35+
protect_breaking_commits = false
36+
filter_commits = false
37+
tag_pattern = "v[0-9]*"
38+
skip_tags = ""
39+
ignore_tags = ""
40+
date_order = false
41+
sort_commits = "oldest"

0 commit comments

Comments
 (0)