From 0d4e689115bdef19b3c44d110bde81820201518f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 27 Apr 2023 00:39:42 +0300 Subject: [PATCH] feat(config): add a custom configuration file for the repository --- .github/workflows/cd.yml | 2 +- cliff.toml | 86 +++++++++++++++++++++++++++ release.sh | 4 +- website/docs/templating/examples.md | 92 ++++++++++++++++++++++++++++- 4 files changed, 179 insertions(+), 5 deletions(-) create mode 100644 cliff.toml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 80d70afbde..60eb62df19 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -23,7 +23,7 @@ jobs: uses: orhun/git-cliff-action@v2 id: git-cliff with: - config: config/cliff.toml + config: cliff.toml args: -vv --latest --strip header env: OUTPUT: CHANGES.md diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000000..e37bb009f6 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,86 @@ +# git-cliff ~ configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://tera.netlify.app/docs/ +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + - *({{commit.scope}})*{% if commit.breaking %} [**breaking**]{% endif %} \ + {{ commit.message | upper_first }} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if commit.scope -%} + {% else -%} + - *(uncategorized)*{% if commit.breaking %} [**breaking**]{% endif %} \ + {{ commit.message | upper_first }} + {% endif -%} + {% endfor -%} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ + +""" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))" }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "โ›ฐ๏ธ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# glob pattern for matching git tags +tag_pattern = "v[0-9]*" +# regex for skipping tags +skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "newest" diff --git a/release.sh b/release.sh index 1162cfaaab..de535c44a6 100755 --- a/release.sh +++ b/release.sh @@ -13,9 +13,7 @@ sed -E -i "s/^version = .* $msg$/version = \"${1#v}\" $msg/" git-cliff*/Cargo.to sed -E -i "s/\"version\": \".+\"/\"version\": \"${1#v}\"/" npm/git-cliff/package.json sed -E -i "s/\"(git-cliff-.+)\": \".+\"/\"\1\": \"${1#v}\"/g" npm/git-cliff/package.json # update the changelog -sed -E -i "s/\s+\#\s(.*)\s\#\sreplace issue numbers/\\t\1/g" config/cliff.toml -cargo run -- --tag "$1" >CHANGELOG.md -git restore config/cliff.toml +cargo run -- --config cliff.toml -tag "$1" >CHANGELOG.md git add -A && git commit -m "chore(release): prepare for $1" git show # generate a changelog for the tag message diff --git a/website/docs/templating/examples.md b/website/docs/templating/examples.md index b66614c07c..0948e78c91 100644 --- a/website/docs/templating/examples.md +++ b/website/docs/templating/examples.md @@ -20,7 +20,7 @@ See [examples](https://github.com/orhun/git-cliff/tree/main/examples) directory If you have a custom configuration file that you are using for your project(s), consider sharing it with us by [submitting a pull request](https://github.com/orhun/git-cliff/blob/main/CONTRIBUTING.md)! -#### [Basic](https://github.com/orhun/git-cliff/tree/main/config/cliff.toml) +#### [Basic (default)](https://github.com/orhun/git-cliff/tree/main/config/cliff.toml)
Raw Output @@ -110,6 +110,96 @@ All notable changes to this project will be documented in this file.
+#### [Styled and scoped](https://github.com/orhun/git-cliff/tree/main/cliff.toml) + +
+ Raw Output + +``` +# Changelog + +All notable changes to this project will be documented in this file. + +## [unreleased] + +### โ›ฐ๏ธ Features + +- *(cache)* Use cache while fetching pages +- *(config)* Support multiple file formats + +## [1.0.1] - 2021-07-18 + +### ๐Ÿšœ Refactor + +- *(parser)* Expose string functions + +### โš™๏ธ Miscellaneous Tasks + +- *(release)* Add release script + +## [1.0.0] - 2021-07-18 + +### โ›ฐ๏ธ Features + +- *(parser)* Add ability to parse arrays + +### ๐Ÿ› Bug Fixes + +- *(args)* Rename help argument due to conflict + +### ๐Ÿ“š Documentation + +- *(example)* [**breaking**] Add tested usage example +- *(project)* Add README.md + + +``` + +
+ +
+ Rendered Output + +# Changelog + +All notable changes to this project will be documented in this file. + +## [unreleased] + +### โ›ฐ๏ธ Features + +- _(cache)_ Use cache while fetching pages +- _(config)_ Support multiple file formats + +## [1.0.1] - 2021-07-18 + +### ๐Ÿšœ Refactor + +- _(parser)_ Expose string functions + +### โš™๏ธ Miscellaneous Tasks + +- _(release)_ Add release script + +## [1.0.0] - 2021-07-18 + +### โ›ฐ๏ธ Features + +- _(parser)_ Add ability to parse arrays + +### ๐Ÿ› Bug Fixes + +- _(args)_ Rename help argument due to conflict + +### ๐Ÿ“š Documentation + +- _(example)_ [**breaking**] Add tested usage example +- _(project)_ Add README.md + + + +
+ #### [Minimal](https://github.com/orhun/git-cliff/tree/main/examples/minimal.toml)