@@ -51,6 +51,8 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
51
51
52
52
const proposedReleaseVersion = 'v' + semver . inc ( fromVersion , calculatedBump , undefined , tag )
53
53
54
+ console . log ( `Generating release notes for ${ fromVersion } to ${ toVersion } ...` )
55
+
54
56
console . log ( {
55
57
tag,
56
58
recommendedBump,
@@ -61,20 +63,56 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
61
63
62
64
const conventionalCommits = await getLatestCommits ( fromVersion , toVersion )
63
65
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
+ }
65
99
66
100
const sections = conventionalCommits . reduce (
67
101
( sections , c ) => {
68
102
if ( c . isBreaking ) {
69
103
sections . breaking . push ( c )
70
104
}
71
105
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
+ }
73
110
sections [ c . type ] . push ( c )
74
111
}
112
+
75
113
return sections
76
114
} ,
77
- { feat : [ ] , fix : [ ] , perf : [ ] , breaking : [ ] } as Record < SectionKey , GitCommit [ ] > ,
115
+ { } as Record < Sections | 'breaking' , GitCommit [ ] > ,
78
116
)
79
117
80
118
// Sort commits by scope, unscoped first
@@ -96,18 +134,10 @@ export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogRe
96
134
// Might need to swap out HEAD for the new proposed version
97
135
let changelog = `## [${ proposedReleaseVersion } ](https://github.com/payloadcms/payload/compare/${ fromVersion } ...${ proposedReleaseVersion } ) (${ yyyyMMdd } )\n\n\n`
98
136
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
+ }
111
141
}
112
142
113
143
// Add contributors after writing to file
0 commit comments