-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate a changelog upon release (#17)
* detect if CHANGELOG was altered * tested locally * fix changelog for v1.x branches
- Loading branch information
Showing
4 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# git-cliff ~ configuration file | ||
# https://git-cliff.org/docs/configuration | ||
|
||
[changelog] | ||
# template for the changelog header | ||
header = """ | ||
# Changelog\n | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
<!-- markdownlint-disable MD024 -->\n | ||
""" | ||
# template for the changelog body | ||
# https://keats.github.io/tera/docs/#introduction | ||
body = """ | ||
{%- macro remote_url() -%} | ||
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} | ||
{%- endmacro -%} | ||
{%- set init_commit = get_env(name="FIRST_COMMIT", default="") -%} | ||
{%- set this_version = "Unreleased" -%} | ||
{% if version -%} | ||
{%- set this_version = version | trim_start_matches(pat="v") -%} | ||
## [{{ this_version }}] - {{ timestamp | date(format="%Y-%m-%d") }} | ||
{%- if message %} | ||
> {{ message }} | ||
{%- endif %} | ||
{% else -%} | ||
## [Unreleased] | ||
{% endif -%} | ||
{% for group, commits in commits | group_by(attribute="group") %} | ||
### {{ group | upper_first }} | ||
{% for commit in commits | unique(attribute="message") %} | ||
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\ | ||
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%} | ||
{% if commit.remote.pr_number %} in \ | ||
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) | ||
{%- else %} in \ | ||
[`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }}) | ||
{%- endif -%} | ||
{% endfor %} | ||
{% endfor -%} | ||
{% set first_commit = previous.version -%} | ||
{%- set last_commit = "HEAD" -%} | ||
{% if version -%} | ||
{%- set last_commit = version -%} | ||
{%- if not previous.version -%} | ||
{%- set first_commit = init_commit -%} | ||
{%- endif -%} | ||
{%- endif %} | ||
[{{ this_version }}]: {{ self::remote_url() }}/compare/{{ first_commit }}...{{ last_commit }} | ||
Full commit diff: [`{% if previous.version -%} | ||
{{ first_commit }} | ||
{%- else -%} | ||
{{ init_commit | truncate(length=7, end="") }} | ||
{%- endif %}...{{ last_commit }}`][{{ this_version }}] | ||
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} | ||
## New Contributors | ||
{%- endif -%} | ||
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} | ||
* @{{ contributor.username }} made their first contribution | ||
{%- if contributor.pr_number %} in \ | ||
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \ | ||
{%- endif %} | ||
{%- endfor %}\n | ||
""" | ||
# template for the changelog footer | ||
footer = """ | ||
<!-- generated by git-cliff --> | ||
""" | ||
# remove the leading and trailing whitespace from the templates | ||
trim = true | ||
# The file path for output. This can be overridden with `--output` CLI arg | ||
# output = "CHANGELOG.md" | ||
|
||
[git] | ||
# parse the commits based on https://www.conventionalcommits.org | ||
conventional_commits = true | ||
# filter out the commits that are not conventional | ||
filter_unconventional = false | ||
# regex for preprocessing the commit messages | ||
commit_preprocessors = [ | ||
# remove issue numbers from commits | ||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }, | ||
] | ||
# regex for parsing and grouping commits | ||
commit_parsers = [ | ||
{ field = "github.pr_labels", pattern = "breaking", group = "<!-- 0 --> 💥 Breaking changes" }, | ||
{ field = "github.pr_labels", pattern = "breaking-change", group = "<!-- 0 --> 💥 Breaking changes" }, | ||
{ field = "github.pr_labels", pattern = "feature", group = "<!-- 1 --> 🚀 Added" }, | ||
{ field = "github.pr_labels", pattern = "enhancement", group = "<!-- 1 --> 🚀 Added" }, | ||
{ field = "github.pr_labels", pattern = "deprecated", group = "<!-- 2 --> 🚫 Deprecated" }, | ||
{ field = "github.pr_labels", pattern = "removed", group = "<!-- 3 --> 🗑️ Removed" }, | ||
{ field = "github.pr_labels", pattern = "bug", group = "<!-- 4 --> 🛠️ Fixed" }, | ||
{ field = "github.pr_labels", pattern = "security", group = "<!-- 5 --> 🔐 Security" }, | ||
{ field = "github.pr_labels", pattern = "dependencies", group = "<!-- 6 --> 📦 Dependency updates" }, | ||
{ field = "github.pr_labels", pattern = "test", group = "<!-- 7 -->🚦 Tests"}, | ||
{ field = "github.pr_labels", pattern = "tests", group = "<!-- 7 -->🚦 Tests"}, | ||
{ field = "github.pr_labels", pattern = "documentation", group = "<!-- 8 --> 📝 Documentation" }, | ||
{ field = "github.pr_labels", pattern = "refactor", group = "<!-- 9 --> 🗨️ Changed" }, | ||
{ field = "github.pr_labels", pattern = "skip-changelog", skip = true }, | ||
{ field = "github.pr_labels", pattern = "no-changelog", skip = true }, | ||
{ field = "github.pr_labels", pattern = "invalid", skip = true }, | ||
# The order of parsers matters. Put rules for PR labels first to prioritize PR labels. | ||
{ message = "^[a|A]dd", group = "<!-- 1 --> 🚀 Added" }, | ||
{ message = "^[s|S]upport", group = "<!-- 1 --> 🚀 Added" }, | ||
{ message = "^.*: support", group = "<!-- 1 --> 🚀 Added" }, | ||
{ message = "^.*: add", group = "<!-- 1 --> 🚀 Added" }, | ||
{ message = "^.*: deprecated", group = "<!-- 2 --> 🚫 Deprecated" }, | ||
{ message = "[d|D]eprecate", group = "<!-- 2 --> 🚫 Deprecated" }, | ||
{ message = "[t|T]ests", group = "<!-- 7 -->🚦 Tests"}, | ||
{ message = "[r|R]emove", group = "<!-- 3 --> 🗑️ Removed" }, | ||
{ message = "^.*: remove", group = "<!-- 3 --> 🗑️ Removed" }, | ||
{ message = "^.*: delete", group = "<!-- 3 --> 🗑️ Removed" }, | ||
{ message = "^[f|F]ix", group = "<!-- 4 --> 🛠️ Fixed" }, | ||
{ message = "^.*: fix", group = "<!-- 4 --> 🛠️ Fixed" }, | ||
{ message = "^.*: secure", group = "<!-- 5 --> 🔐 Security" }, | ||
{ message = "[s|S]ecure", group = "<!-- 5 --> 🔐 Security" }, | ||
{ message = "[s|S]ecurity", group = "<!-- 5 --> 🔐 Security" }, | ||
{ message = "^.*: security", group = "<!-- 5 --> 🔐 Security" }, | ||
{ message = "doc", group = "<!-- 8 --> 📝 Documentation" }, | ||
{ message = "docs", group = "<!-- 8 --> 📝 Documentation" }, | ||
{ message = "documentation", group = "<!-- 8 --> 📝 Documentation" }, | ||
{ message = "[r|R]efactor", group = "<!-- 9 --> 🗨️ Changed" }, | ||
{ field = "github.pr_labels", pattern = ".*", group = "<!-- 9 --> 🗨️ Changed" }, | ||
{ message = "^.*", group = "<!-- 9 --> 🗨️ Changed" }, | ||
] | ||
# filter out the commits that are not matched by commit parsers | ||
filter_commits = true | ||
# sort the tags topologically | ||
topo_order = false | ||
# sort the commits inside sections by oldest/newest order | ||
sort_commits = "oldest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
.github/workflows/ReleaseNotes.md |