Skip to content

Commit be22d39

Browse files
authored
chore(ci): categorized changelog from commit labels (#2323)
1 parent ae8fa9e commit be22d39

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

.github/release.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1+
# Note: GitHub's release.yml only supports label-based categorization, not commit message patterns.
2+
# We generate categorized changelog from commit messages in the release workflow instead.
3+
# This file is kept for potential future label-based categorization.
14
changelog:
25
categories:
36
- title: "🚀 Features"
4-
# Match PR titles starting with "feat:"
5-
any:
6-
- "title:/^feat:/i"
7-
- title: "🐛 Bug Fixes"
8-
# Match PR titles starting with "fix:"
9-
any:
10-
- "title:/^fix:/i"
11-
- title: "📝 Other Changes"
12-
# Catch-all for everything else (docs, chore, refactor, etc.)
13-
any:
7+
labels:
148
- "*"

.github/workflows/release.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
release:
7-
description: 'Release version (e.g., v1.2.3). Leave empty to calculate from semantic commits.'
7+
description: "Release version (e.g., v1.2.3). Leave empty to calculate from semantic commits."
88
required: false
99
type: string
1010

@@ -59,15 +59,15 @@ jobs:
5959
- name: Conventional Changelog Update
6060
uses: TriPSs/conventional-changelog-action@84dadaf2c367cb52af02737cd9c7e888807219e7 # v6
6161
id: changelog
62-
if: ${{ inputs.release == '' }}
6362
continue-on-error: true
6463
with:
6564
github-token: ${{ github.token }}
66-
output-file: 'CHANGELOG.md'
67-
skip-version-file: 'true'
68-
skip-commit: 'true'
69-
skip-on-empty: 'false'
70-
git-push: 'true'
65+
output-file: "CHANGELOG.md"
66+
skip-version-file: "true"
67+
skip-commit: "true"
68+
skip-tag: ${{ inputs.release != '' }}
69+
skip-on-empty: "false"
70+
git-push: ${{ inputs.release == '' }}
7171

7272
- name: Set Final Version
7373
id: set-version
@@ -80,8 +80,35 @@ jobs:
8080
echo "version=${{ steps.changelog.outputs.version }}" >> $GITHUB_OUTPUT
8181
fi
8282
83+
- name: Get Previous Tag
84+
id: previous-tag
85+
run: |
86+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || git tag --sort=-creatordate | head -2 | tail -1 || echo "")
87+
if [ -z "$PREV_TAG" ]; then
88+
PREV_TAG=$(git rev-list --max-parents=0 HEAD | head -1)
89+
fi
90+
echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
91+
92+
- name: Generate Categorized Changelog
93+
id: changelog-body
94+
continue-on-error: true
95+
uses: requarks/changelog-action@v1
96+
with:
97+
token: ${{ github.token }}
98+
# Note: Action's parameter names are confusing:
99+
# fromTag = newer tag (latest/release tag)
100+
# toTag = older tag (previous tag)
101+
# Action compares: toTag...fromTag (commits between old and new)
102+
fromTag: ${{ steps.set-version.outputs.tag }} # New release tag (e.g., v0.2.0)
103+
toTag: ${{ steps.previous-tag.outputs.tag }} # Previous tag (e.g., v0.1.0)
104+
writeToFile: false
105+
useGitmojis: false
106+
excludeTypes: "build,docs,other,style"
107+
includeInvalidCommits: false
108+
includeRefIssues: false
109+
83110
- name: Create Release
84-
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
111+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
85112
if: steps.set-version.outputs.tag != ''
86113
continue-on-error: true
87114
env:
@@ -90,7 +117,8 @@ jobs:
90117
token: ${{ github.token }}
91118
tag_name: ${{ steps.set-version.outputs.tag }}
92119
name: ${{ steps.set-version.outputs.tag }}
93-
generate_release_notes: true
120+
body: ${{ steps.changelog-body.outputs.changes }}
121+
generate_release_notes: false
94122

95123
deploys-test:
96124
name: TEST Deploys (${{ needs.vars.outputs.pr }})

0 commit comments

Comments
 (0)