Skip to content

Commit f9bdab9

Browse files
committed
ci: add automated changelog generation and GitHub releases
- Add git-cliff configuration (cliff.toml) for generating changelogs from commit messages following Keep a Changelog format - Update release workflow to automatically generate changelog and create GitHub releases with release notes when a version tag is pushed - Uses git-cliff 2.10.1 for parsing commit history and extracting issues/PRs references
1 parent 32a415d commit f9bdab9

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,38 @@ jobs:
7272
env:
7373
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
7474
run: cargo +${{ steps.msrv.outputs.msrv }} publish --locked --token "$CARGO_REGISTRY_TOKEN"
75+
76+
release:
77+
runs-on: ubuntu-latest
78+
needs: publish
79+
permissions:
80+
contents: write
81+
steps:
82+
- uses: actions/checkout@v5
83+
with:
84+
fetch-depth: 0
85+
86+
- name: Install git-cliff
87+
uses: taiki-e/install-action@v2
88+
with:
89+
90+
91+
- name: Generate changelog
92+
id: changelog
93+
shell: bash
94+
run: |
95+
TAG="${GITHUB_REF#refs/tags/}"
96+
97+
# Generate changelog for current tag only
98+
CHANGELOG=$(git cliff --current --strip header)
99+
100+
# Save to output using multiline format
101+
echo "content<<EOF" >> "$GITHUB_OUTPUT"
102+
echo "$CHANGELOG" >> "$GITHUB_OUTPUT"
103+
echo "EOF" >> "$GITHUB_OUTPUT"
104+
105+
- name: Create GitHub Release
106+
uses: softprops/action-gh-release@v2
107+
with:
108+
body: ${{ steps.changelog.outputs.content }}
109+
generate_release_notes: false

cliff.toml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# git-cliff configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
# Changelog header
6+
header = """
7+
# Changelog
8+
9+
All notable changes to this project will be documented in this file.
10+
11+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
12+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
13+
"""
14+
15+
# Template for changelog body
16+
body = """
17+
{% if version %}\
18+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
19+
{% else %}\
20+
## [Unreleased]
21+
{% endif %}\
22+
{% for group, commits in commits | group_by(attribute="group") %}
23+
### {{ group | striptags | trim | upper_first }}
24+
{% for commit in commits %}
25+
- {{ commit.message | upper_first }}
26+
{% endfor %}
27+
{% endfor %}\n
28+
"""
29+
30+
# Template for changelog footer
31+
footer = """
32+
<!-- generated by git-cliff -->
33+
"""
34+
35+
# Remove the leading and trailing whitespace from the template
36+
trim = true
37+
38+
[git]
39+
# Parse commits based on https://www.conventionalcommits.org
40+
conventional_commits = false
41+
# Filter unconventional commits
42+
filter_unconventional = false
43+
# Split the commit message by pattern
44+
split_commits = false
45+
46+
# Regex for preprocessing commit messages
47+
commit_preprocessors = [
48+
# Transform "#123 type: description" to "type: description (#123)"
49+
{ pattern = '^#(\d+)\s+(.+)$', replace = "${2} (#${1})" },
50+
]
51+
52+
# Regex for parsing commit messages
53+
commit_parsers = [
54+
{ message = "^feat", group = "Added" },
55+
{ message = "^add", group = "Added" },
56+
{ message = "^fix", group = "Fixed" },
57+
{ message = "^perf", group = "Changed" },
58+
{ message = "^refactor", group = "Changed" },
59+
{ message = "^docs", group = "Changed" },
60+
{ message = "^test", group = "Changed" },
61+
{ message = "^chore\\(release\\): prepare for", skip = true },
62+
{ message = "^chore\\(deps.*\\)", skip = true },
63+
{ message = "^chore\\(pr\\)", skip = true },
64+
{ message = "^chore\\(pull\\)", skip = true },
65+
{ message = "^chore: bump version", skip = true },
66+
{ message = "^Merge pull request", skip = true },
67+
{ message = "^Merge branch", skip = true },
68+
{ message = "^deps\\(", skip = true },
69+
{ message = "^ci", skip = true },
70+
{ body = ".*security", group = "Security" },
71+
{ message = "^revert", group = "Reverted" },
72+
]
73+
74+
# Protect breaking changes from being skipped due to matching a skipping commit_parser
75+
protect_breaking_commits = false
76+
77+
# Filter out commits that match the specified patterns
78+
filter_commits = false
79+
80+
# Glob pattern for matching git tags
81+
tag_pattern = "v[0-9].*"
82+
83+
# Sort tags chronologically
84+
date_order = false
85+
sort_commits = "oldest"
86+
87+
# Link parsers for extracting external references
88+
link_parsers = [
89+
{ pattern = "\\(#(\\d+)\\)", href = "https://github.com/RAprogramm/telegram-webapp-sdk/issues/$1", text = "#$1" },
90+
]

0 commit comments

Comments
 (0)