patternbashTip
Changelog generation with git-cliff from conventional commits
Viewed 0 times
orhun/git-cliff-action@v3
git-cliffchangelogconventional commitsrelease notesfilterbreaking change
Problem
Writing CHANGELOGs manually is tedious and inevitably incomplete. Auto-generated changelogs from all commits are noisy and include irrelevant chore and CI commits that users do not care about.
Solution
Use git-cliff to generate filtered, categorised changelogs:
In CI:
# cliff.toml
[changelog]
header = "# Changelog\n\n"
body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}{% if commit.breaking %} [**breaking**]{% endif %}
{% endfor %}
{% endfor %}
"""
trim = true
[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^chore|^ci|^build", skip = true },
]In CI:
- uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --latest --strip header
env:
OUTPUT: CHANGELOG.mdWhy
skip = true for chore/ci/build commits removes noise. Grouping by type gives users a clear view of what changed. --latest generates only the changelog for the current release, not the entire history.
Gotchas
- git-cliff requires full git history—use fetch-depth: 0 in the checkout step
- Breaking changes are only detected if the commit uses the ! suffix or includes 'BREAKING CHANGE:' in the footer
- The generated CHANGELOG.md must be committed back to the repo by the release workflow
Revisions (0)
No revisions yet.