Skip to content

Commit e4c3c5b

Browse files
authored
ci: allow more commit types in release notes (#9677)
More commit types will now show in the release notes. The full list of allowable types are the following and will show in order: ```ts const commitTypesForChangelog = [ 'feat', 'fix', 'perf', 'refactor', 'docs', 'style', 'test', 'templates', 'examples', 'build', 'ci', 'chore', ] ```
1 parent 58b7415 commit e4c3c5b

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

.github/workflows/pr-title.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ jobs:
2424
chore
2525
ci
2626
docs
27+
examples
2728
feat
2829
fix
2930
perf
3031
refactor
3132
revert
3233
style
34+
templates
3335
test
34-
types
3536
scopes: |
3637
cpa
3738
db-\*

scripts/utils/generateReleaseNotes.ts

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
5151

5252
const proposedReleaseVersion = 'v' + semver.inc(fromVersion, calculatedBump, undefined, tag)
5353

54+
console.log(`Generating release notes for ${fromVersion} to ${toVersion}...`)
55+
5456
console.log({
5557
tag,
5658
recommendedBump,
@@ -61,20 +63,56 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
6163

6264
const conventionalCommits = await getLatestCommits(fromVersion, toVersion)
6365

64-
type SectionKey = 'breaking' | 'feat' | 'fix' | 'perf'
66+
const commitTypesForChangelog = [
67+
'feat',
68+
'fix',
69+
'perf',
70+
'refactor',
71+
'docs',
72+
'style',
73+
'test',
74+
'templates',
75+
'examples',
76+
'build',
77+
'ci',
78+
'chore',
79+
'breaking',
80+
] as const
81+
82+
type Sections = (typeof commitTypesForChangelog)[number]
83+
84+
const emojiHeaderMap: Record<Sections, string> = {
85+
feat: '🚀 Features',
86+
fix: '🐛 Bug Fixes',
87+
perf: '⚡ Performance',
88+
refactor: '🛠 Refactors',
89+
docs: '📚 Documentation',
90+
style: '🎨 Styles',
91+
test: '🧪 Tests',
92+
templates: '📝 Templates',
93+
examples: '📓 Examples',
94+
build: '🔨 Build',
95+
ci: '⚙️ CI',
96+
chore: '🏡 Chores',
97+
breaking: '⚠️ BREAKING CHANGES',
98+
}
6599

66100
const sections = conventionalCommits.reduce(
67101
(sections, c) => {
68102
if (c.isBreaking) {
69103
sections.breaking.push(c)
70104
}
71105

72-
if (['feat', 'fix', 'perf'].includes(c.type)) {
106+
if (commitTypesForChangelog.includes(c.type as Sections)) {
107+
if (!sections[c.type]) {
108+
sections[c.type] = []
109+
}
73110
sections[c.type].push(c)
74111
}
112+
75113
return sections
76114
},
77-
{ feat: [], fix: [], perf: [], breaking: [] } as Record<SectionKey, GitCommit[]>,
115+
{} as Record<Sections | 'breaking', GitCommit[]>,
78116
)
79117

80118
// Sort commits by scope, unscoped first
@@ -96,18 +134,10 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
96134
// Might need to swap out HEAD for the new proposed version
97135
let changelog = `## [${proposedReleaseVersion}](https://github.com/payloadcms/payload/compare/${fromVersion}...${proposedReleaseVersion}) (${yyyyMMdd})\n\n\n`
98136

99-
// Add section headers
100-
if (stringifiedSections.feat.length) {
101-
changelog += `### 🚀 Features\n\n${stringifiedSections.feat.join('\n')}\n\n`
102-
}
103-
if (stringifiedSections.perf.length) {
104-
changelog += `### ⚡ Performance\n\n${stringifiedSections.perf.join('\n')}\n\n`
105-
}
106-
if (stringifiedSections.fix.length) {
107-
changelog += `### 🐛 Bug Fixes\n\n${stringifiedSections.fix.join('\n')}\n\n`
108-
}
109-
if (stringifiedSections.breaking.length) {
110-
changelog += `### ⚠️ BREAKING CHANGES\n\n${stringifiedSections.breaking.join('\n')}\n\n`
137+
for (const section of commitTypesForChangelog) {
138+
if (stringifiedSections[section]?.length) {
139+
changelog += `### ${emojiHeaderMap[section]}\n\n${stringifiedSections[section].join('\n')}\n\n`
140+
}
111141
}
112142

113143
// Add contributors after writing to file

0 commit comments

Comments
 (0)