Skip to content

Commit

Permalink
feat: Create changelog for GH releases
Browse files Browse the repository at this point in the history
  • Loading branch information
yanliu38 committed Jan 25, 2025
1 parent e31da8f commit 238003f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,27 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Install git-cliff
uses: orhun/git-cliff-action@v2
with:
config: cliff.toml
args: --current --strip header

- name: Generate changelog
id: changelog
run: |
echo "changelog<<EOF" >> $GITHUB_OUTPUT
git-cliff --current --strip header >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -24,6 +41,9 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
body: |
## Changelog
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false

Expand Down
41 changes: 41 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.
"""

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 | upper_first }}
{% for commit in commits %}
* {% if commit.breaking %}**Breaking:** {% endif %}{{ commit.message | upper_first }}{% if commit.id %} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})){% endif %}
{% endfor %}
{% endfor %}\n
"""

trim = true
footer = ""

[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^docs", 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", group = "Miscellaneous Tasks" },
]
protect_breaking_commits = false
filter_commits = false
tag_pattern = "v[0-9]*"
skip_tags = ""
ignore_tags = ""
date_order = false
sort_commits = "oldest"

0 comments on commit 238003f

Please sign in to comment.