chore: Improve the changelog

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-05-21 21:35:47 +00:00
parent c5085b3af7
commit 92165de6fd
2 changed files with 24 additions and 17 deletions

View File

@@ -17,12 +17,13 @@ body = """
{% if version -%} {% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%} {% else -%}
## [Unreleased] ## Unreleased
{% endif -%} {% endif -%}
{% for group, commits in commits | group_by(attribute="group") %} {% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }} ### {{ group | upper_first }}
{% for commit in commits %} {% for commit in commits %}
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\ - {{ commit.message | split(pat="\n") | first | split(pat=":") | slice(start=1) | join(sep=":") | upper_first | trim }} - \
({{ commit.author.name}} at [{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/?id={{ commit.id }}))\
{% endfor %} {% endfor %}
{% endfor %}\n {% endfor %}\n
""" """
@@ -31,12 +32,7 @@ body = """
footer = """ footer = """
{% for release in releases -%} {% for release in releases -%}
{% if release.version -%} {% if release.version -%}
{% if release.previous.version -%} [{{ release.version | trim_start_matches(pat="v") }}]: https://git.4rs.nl/awiteb/n34.git/tag/?h={{ release.version }}
[{{ release.version | trim_start_matches(pat="v") }}]: \
https://git.4rs.nl/awiteb/n34/compare/{{ release.previous.version }}..{{ release.version }}
{% endif -%}
{% else -%}
[unreleased]: https://git.4rs.nl/awiteb/n34/compare/{{ release.previous.version }}..HEAD
{% endif -%} {% endif -%}
{% endfor %} {% endfor %}
<!-- generated by git-cliff --> <!-- generated by git-cliff -->
@@ -44,6 +40,11 @@ footer = """
# Remove leading and trailing whitespaces from the changelog's body. # Remove leading and trailing whitespaces from the changelog's body.
trim = true trim = true
postprocessors = [
# Replace the placeholder `<REPO>` with a URL.
{ pattern = '\$REPO', replace = "https://git.4rs.nl/awiteb/n34.git" },
]
[git] [git]
# Parse commits according to the conventional commits specification. # Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org # See https://www.conventionalcommits.org
@@ -54,14 +55,14 @@ filter_unconventional = false
# Assigns commits to groups. # Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing. # Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [ commit_parsers = [
{ message = "^.*!:.*$", group = "Breaking Change" }, { message = '^.*!:.*$', group = "Breaking Change" },
{ message = "^feat", group = "Added" }, { message = '^feat', group = "Added" },
{ message = "^deprecate", group = "Deprecated" }, { message = '^deprecate', group = "Deprecated" },
{ message = "^remove", group = "Removed" }, { message = '^remove', group = "Removed" },
{ message = "^deps", group = "Dependencies" }, { message = '^deps', group = "Dependencies" },
{ message = "^refactor", group = "Refactor" }, { message = '^refactor', group = "Refactor" },
{ message = "^fix", group = "Fixed" }, { message = '^fix', group = "Fixed" },
{ message = "^docs", group = "Documentation" }, { message = '^docs', group = "Documentation" },
] ]
# Prevent commits that are breaking from being excluded by commit parsers. # Prevent commits that are breaking from being excluded by commit parsers.
filter_commits = false filter_commits = false

View File

@@ -14,6 +14,12 @@ JUST_EXECUTABLE := "just -u -f " + justfile()
header := "Available tasks:\n" header := "Available tasks:\n"
# Get the MSRV from the Cargo.toml # Get the MSRV from the Cargo.toml
msrv := `cat Cargo.toml | grep "rust-version" | sed 's/.*"\(.*\)".*/\1/'` msrv := `cat Cargo.toml | grep "rust-version" | sed 's/.*"\(.*\)".*/\1/'`
tag_change_body := '''{% for group, commits in commits | group_by(attribute="group") %}
{{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | split(pat="\n") | first | split(pat=":") | slice(start=1) | join(sep=":") | upper_first | trim }} - (by {{ commit.author.name}}){% endfor %}{% endfor %}'''
export TZ := "UTC" export TZ := "UTC"
@@ -58,7 +64,7 @@ changelog:
[script] [script]
release version: release version:
set -e set -e
TAG_MSG=$(git-cliff --strip all --unreleased --tag "v{{ version }}" | sed -e 's/[]#[]//g' -e 's/^ //g') TAG_MSG=$(git-cliff --strip all --unreleased --body '{{ tag_change_body }}')
sed -i "s/^version\s*= \".*\"/version = \"{{ version }}\"/" ./Cargo.toml sed -i "s/^version\s*= \".*\"/version = \"{{ version }}\"/" ./Cargo.toml
taplo fmt --config ./.taplo.toml ./Cargo.toml taplo fmt --config ./.taplo.toml ./Cargo.toml
{{ JUST_EXECUTABLE }} ci {{ JUST_EXECUTABLE }} ci