Skip to content

Commit

Permalink
chore: add post- and preprocessing for release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mryel00 committed Oct 27, 2023
1 parent 54471dc commit 180da33
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 29 deletions.
41 changes: 27 additions & 14 deletions cliff-release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ header = """
# https://tera.netlify.app/docs/#introduction
body = """
{% for group, commits in commits | group_by(attribute="group") %}\
### {{ group | split(pat="$") | last | upper_first }}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
- **{{commit.scope}}**: {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](https://github.com/mainsail-crew/crowsnest/commit/{{ commit.id }})\
- **{{commit.scope}}**: {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }})\
{%- if commit.breaking %}
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
{%- endif -%}
Expand All @@ -23,7 +23,8 @@ body = """
{%- if commit.scope -%}
{% else -%}
{% raw %}\n{% endraw %}\
- {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](https://github.com/mainsail-crew/crowsnest/commit/{{ commit.id }})\
- {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }})\
{%- if commit.breaking %}
{%- if commit.breaking %}
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
{%- endif -%}
Expand All @@ -39,28 +40,40 @@ trim = true
footer = """
"""

# postprocessors
postprocessors = [
{ pattern = '(\(<REPO>/pull/[0-9]+\)\)) \| .+', replace = "${1}" },
{ pattern = '<REPO>', replace = "https://github.com/mainsail-crew/crowsnest" }, # replace repository URL
]

[git]
# allow only conventional commits
# https://www.conventionalcommits.org
conventional_commits = true
filter_unconventional = true
# regex for parsing and grouping commits
commit_parsers = [
# Commits to skip
{ message = "^docs\\(changelog\\):", group = "Changelog", skip = true}, # Old redundant commits
{ message = "^chore\\(changelog\\): update changelog", group = "Changelog", skip = true}, # Old redundant commits
{ message = "^chore: push version number to", group = "9$Other", skip = true}, # Old redundant commits
{ message = "^feat(\\(.*\\))?:", group = "1$Features"},
{ message = "^feature(\\(.*\\))?:", group = "1$Features"},
{ message = "^fix(\\(.*\\))?:", group = "2$Bug Fixes and Improvements"},
{ message = "^docs(\\(.*\\))?:", group = "7$Documentation"},
{ message = "^perf(\\(.*\\))?:", group = "3$Performance"},
{ message = "^refactor(\\(.*\\))?:", group = "4$Refactor"},
{ message = "^style(\\(.*\\))?:", group = "5$Styling"},
{ message = "^test(\\(.*\\))?:", group = "9$Other"},
{ message = "^locale(\\(.*\\))?:", group = "6$Localization"},
{ message = "^chore(\\(.*\\))?:", group = "9$Other"},
{ message = "^chore\\(changelog\\): update changelog", group = "Changelog", skip = true}, # Old redundant commits

# Commits to parse
{ message = "^feat(\\(.*\\))?:", group = "<!-- 1 -->Features"},
{ message = "^feature(\\(.*\\))?:", group = "<!-- 1 -->Features"},
{ message = "^fix(\\(.*\\))?:", group = "<!-- 2 -->Bug Fixes and Improvements"},
{ message = "^perf(\\(.*\\))?:", group = "<!-- 3 -->Performance"},
{ message = "^refactor(\\(.*\\))?:", group = "<!-- 4 -->Refactor"},
{ message = "^style(\\(.*\\))?:", group = "<!-- 5 -->Styling"},
{ message = "^locale(\\(.*\\))?:", group = "<!-- 6 -->Localization"},
{ message = "^docs(\\(.*\\))?:", group = "<!-- 7 -->Documentation"},
{ message = "^test(\\(.*\\))?:", group = "<!-- 8 -->Other"},
{ message = "^chore(\\(.*\\))?:", group = "<!-- 8 -->Other"},
{ body = ".*security", group = "Security"},
]
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
ignore_tags="v*-(beta|rc)*"
Expand Down
41 changes: 26 additions & 15 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ body = """
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}\
### {{ group | split(pat="$") | last | upper_first }}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
- **{{commit.scope}}**: {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](https://github.com/mainsail-crew/crowsnest/commit/{{ commit.id }})\
- **{{commit.scope}}**: {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }})\
{%- if commit.breaking %}
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
{%- endif -%}
Expand All @@ -30,7 +30,7 @@ body = """
{%- if commit.scope -%}
{% else -%}
{% raw %}\n{% endraw %}\
- {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](https://github.com/mainsail-crew/crowsnest/commit/{{ commit.id }})\
- {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }})\
{%- if commit.breaking %}
{% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
{%- endif -%}
Expand All @@ -45,28 +45,39 @@ trim = true
footer = """
"""

# postprocessors
postprocessors = [
{ pattern = '(\(<REPO>/pull/[0-9]+\)\)) \| .+', replace = "${1}" },
{ pattern = '<REPO>', replace = "https://github.com/mainsail-crew/crowsnest" }, # replace repository URL
]

[git]
# allow only conventional commits
# https://www.conventionalcommits.org
conventional_commits = true
filter_unconventional = false
# regex for parsing and grouping commits
commit_parsers = [
# Commits to skip
{ message = "^docs\\(changelog\\):", group = "Changelog", skip = true}, # Old redundant commits
{ message = "^chore\\(changelog\\): update changelog", group = "Changelog", skip = true}, # Old redundant commits
{ message = "^chore: push version number to", group = "9$Other", skip = true}, # Old redundant commits
{ message = "^feat(\\(.*\\))?:", group = "1$Features"},
{ message = "^feature(\\(.*\\))?:", group = "1$Features"},
{ message = "^fix(\\(.*\\))?:", group = "2$Bug Fixes and Improvements"},
{ message = "^docs(\\(.*\\))?:", group = "7$Documentation"},
{ message = "^perf(\\(.*\\))?:", group = "3$Performance"},
{ message = "^refactor(\\(.*\\))?:", group = "4$Refactor"},
{ message = "^style(\\(.*\\))?:", group = "5$Styling"},
{ message = "^test(\\(.*\\))?:", group = "9$Other"},
{ message = "^locale(\\(.*\\))?:", group = "6$Localization"},
{ message = "^chore(\\(.*\\))?:", group = "9$Other"},
{ message = "^chore\\(changelog\\): update changelog", group = "Changelog", skip = true}, # Old redundant commits

# Commits to parse
{ message = "^feat(\\(.*\\))?:", group = "<!-- 1 -->Features"},
{ message = "^feature(\\(.*\\))?:", group = "<!-- 1 -->Features"},
{ message = "^fix(\\(.*\\))?:", group = "<!-- 2 -->Bug Fixes and Improvements"},
{ message = "^perf(\\(.*\\))?:", group = "<!-- 3 -->Performance"},
{ message = "^refactor(\\(.*\\))?:", group = "<!-- 4 -->Refactor"},
{ message = "^style(\\(.*\\))?:", group = "<!-- 5 -->Styling"},
{ message = "^locale(\\(.*\\))?:", group = "<!-- 6 -->Localization"},
{ message = "^docs(\\(.*\\))?:", group = "<!-- 7 -->Documentation"},
{ message = "^test(\\(.*\\))?:", group = "<!-- 8 -->Other"},
{ message = "^chore(\\(.*\\))?:", group = "<!-- 8 -->Other"},
{ body = ".*security", group = "Security"},
{ message = "release v2.1.2", group = "Release"}, # workaround for v2.1.2 release
]
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
Expand Down

0 comments on commit 180da33

Please sign in to comment.