Skip to content

Commit

Permalink
Update publish.yaml and overhaul cliff.toml configuration
Browse files Browse the repository at this point in the history
Updated `publish.yaml` to write release version to `GITHUB_ENV` and modified arguments for `git-cliff-action`. Overhauled `cliff.toml` configuration, including changes to changelog format, commit parsers, and tag and commit handling.
  • Loading branch information
marcusbooyah committed Apr 4, 2024
1 parent 82cf299 commit 93f80b6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 36 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Write release version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
Expand All @@ -25,7 +30,7 @@ jobs:
- name: Test
run: dotnet test --no-build --verbosity normal
- name: pack
run: dotnet pack --output ./artifacts -p:version=${GITHUB_REF_NAME}
run: dotnet pack --output ./artifacts -p:version=${VERSION}
- name: publish
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: publish-github
Expand All @@ -48,7 +53,7 @@ jobs:
if: "!github.event.release.prerelease"
with:
config: cliff.toml
args: -vv --latest --strip header
args: --latest --tag-pattern ^v[0-9].[0-9].[0-9]$
env:
OUTPUT: CHANGES.md

Expand All @@ -58,7 +63,7 @@ jobs:
if: "github.event.release.prerelease"
with:
config: cliff.toml
args: -vv --latest --unreleased --strip header
args: --latest --unreleased --tag ${GITHUB_REF_NAME} --tag-pattern ^v[0-9].*
env:
OUTPUT: CHANGES.md

Expand Down
84 changes: 51 additions & 33 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# git-cliff ~ default configuration file
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
Expand All @@ -7,36 +7,60 @@

[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
header = """"""
# 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 -%}
{% macro print_commit(commit) -%}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }} - \
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
{% endmacro -%}
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}]\
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
{{ self::print_commit(commit=commit) }}\
{% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
{%- endfor -%}
{% raw %}\n{% endraw %}\
{%- for commit in commits %}
{%- if not commit.scope -%}
{{ self::print_commit(commit=commit) }}\
{% if commit.github.username %} by @{{ commit.github.username }}{%- endif %}
{% endif -%}
{% endfor -%}
{% endfor %}
{% if version %}
{% if previous.version %}
**Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
{% endif %}
{% else -%}
{% raw %}\n{% endraw %}
{% endif %}
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing s
footer = """"""
# remove the leading and trailing whitespace from the templates
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
{ pattern = '<REPO>', replace = "https://github.com/nforgeio/operator-sdk" }, # replace repository URL
]

[git]
Expand All @@ -47,19 +71,19 @@ filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Replace issue numbers
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
commit_preprocessors = []
# { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" },
# # Check spelling of the commit with https://github.com/crate-ci/typos
# # If the spelling is incorrect, it will be automatically fixed.
# { pattern = '.*', replace_command = 'typos --write-changes -' },
#]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->πŸš€ Features" },
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" },
{ message = "^fix", group = "<!-- 1 -->πŸ› Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->πŸ“š Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚑ Performance" },
{ message = "^refactor\\(clippy\\)", skip = true },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->πŸ§ͺ Testing" },
Expand All @@ -75,15 +99,9 @@ commit_parsers = [
protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# regex for matching git tags
# tag_pattern = "v[0-9].*"
# regex for skipping tags
# skip_tags = ""
# regex for ignoring tags
# ignore_tags = ""
ignore_tags = "neonkube.*"
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
# limit the number of commits included in the changelog.
# limit_commits = 42
sort_commits = "newest"

0 comments on commit 93f80b6

Please sign in to comment.