Skip to content

Commit 8eaaee6

Browse files
committed
chore: refactor CI workflows and enhance changelog generation
1 parent cbf1c37 commit 8eaaee6

File tree

5 files changed

+120
-167
lines changed

5 files changed

+120
-167
lines changed

.github/workflows/auto-version.yml

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

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests (verify-templates, Integration tests)
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
verify-templates:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Rust
12+
uses: actions-rs/toolchain@v1
13+
with:
14+
toolchain: stable
15+
override: true
16+
- name: Run verify-templates test
17+
run: cargo test --test verify_templates
18+
19+
tests:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Rust
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: stable
27+
override: true
28+
- name: Run tests
29+
run: cargo test
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# .github/workflows/release-automation.yml
2-
name: Release Automation
1+
name: Update Changelog and Documentation
32

43
on:
54
workflow_dispatch: # Allows manual triggering of the workflow
@@ -49,9 +48,11 @@ jobs:
4948
run: |
5049
if [[ $GITHUB_REF == refs/tags/* ]]; then
5150
# On tag: Generate full history
51+
git-cliff --github-token ${{ secrets.GITHUB_TOKEN }}
5252
git-cliff --output CHANGELOG.md
5353
else
5454
# On push to main: Only unreleased changes
55+
git-cliff --github-token ${{ secrets.GITHUB_TOKEN }}
5556
git-cliff --unreleased --prepend CHANGELOG.md
5657
fi
5758

.github/workflows/verify-templates.yml

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

cliff.toml

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,104 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
14
[changelog]
5+
# A Tera template to be rendered as the changelog's header.
6+
# See https://keats.github.io/tera/docs/#introduction
27
header = """
38
# Changelog\n
4-
All notable changes to this project will be documented in this file.\n
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
513
"""
6-
footer = "Generated by git-cliff"
7-
prepend = true # ← Key change: New sections will be added at the TOP
14+
# A Tera template to be rendered for each release in the changelog.
15+
# See https://keats.github.io/tera/docs/#introduction
816
body = """
9-
{% if version %}
10-
## [{{ version }}]
11-
{% else %}
12-
## [Unreleased]
13-
{% endif %}
17+
{%- macro remote_url() -%}
18+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
19+
{%- endmacro -%}
20+
21+
{% if version -%}
22+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
23+
{% else -%}
24+
## [Unreleased]
25+
{% endif -%}
1426
1527
{% for group, commits in commits | group_by(attribute="group") %}
16-
### {{ group | upper_first }}
17-
{% for commit in commits %}
18-
- {{ commit.message | trim }} ({{ commit.id | truncate(length=7, end="") }})
28+
### {{ group | upper_first }}
29+
{%- for commit in commits %}
30+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
31+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
32+
{% if commit.remote.pr_number %} in \
33+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
34+
{%- endif -%}
35+
{% endfor %}
1936
{% endfor %}
37+
38+
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
39+
## New Contributors
40+
{%- endif -%}
41+
42+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
43+
* @{{ contributor.username }} made their first contribution
44+
{%- if contributor.pr_number %} in \
45+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
46+
{%- endif %}
47+
{%- endfor %}\n
48+
"""
49+
# A Tera template to be rendered as the changelog's footer.
50+
# See https://keats.github.io/tera/docs/#introduction
51+
footer = """
52+
{%- macro remote_url() -%}
53+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
54+
{%- endmacro -%}
55+
56+
{% for release in releases -%}
57+
{% if release.version -%}
58+
{% if release.previous.version -%}
59+
[{{ release.version | trim_start_matches(pat="v") }}]: \
60+
{{ self::remote_url() }}/compare/{{ release.previous.version }}..{{ release.version }}
61+
{% endif -%}
62+
{% else -%}
63+
[unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}..HEAD
64+
{% endif -%}
2065
{% endfor %}
66+
<!-- generated by git-cliff -->
2167
"""
68+
# Remove leading and trailing whitespaces from the changelog's body.
69+
trim = true
2270

2371
[git]
72+
# Parse commits according to the conventional commits specification.
73+
# See https://www.conventionalcommits.org
2474
conventional_commits = true
25-
tag_pattern = "v[0-9]+\\.[0-9]+\\.[0-9]+"
75+
# Exclude commits that do not match the conventional commits specification.
76+
filter_unconventional = false
77+
# An array of regex based parsers to modify commit messages prior to further processing.
78+
commit_preprocessors = [
79+
# Remove issue numbers.
80+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
81+
]
82+
# An array of regex based parsers for extracting data from the commit message.
83+
# Assigns commits to groups.
84+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
2685
commit_parsers = [
27-
# ... (keep your existing commit parsers)
86+
{ message = "^[a|A]dd", group = "Added" },
87+
{ message = "^[s|S]upport", group = "Added" },
88+
{ message = "^[r|R]emove", group = "Removed" },
89+
{ message = "^.*: add", group = "Added" },
90+
{ message = "^.*: support", group = "Added" },
91+
{ message = "^.*: remove", group = "Removed" },
92+
{ message = "^.*: delete", group = "Removed" },
93+
{ message = "^test", group = "Fixed" },
94+
{ message = "^fix", group = "Fixed" },
95+
{ message = "^.*: fix", group = "Fixed" },
96+
{ message = "^.*", group = "Changed" },
2897
]
98+
# Exclude commits that are not matched by any commit parser.
2999
filter_commits = false
100+
# Order releases topologically instead of chronologically.
101+
topo_order = false
102+
# Order of commits in each group/release within the changelog.
103+
# Allowed values: newest, oldest
104+
sort_commits = "newest"

0 commit comments

Comments
 (0)