@@ -21,7 +21,7 @@ type ChangelogFactory = (
2121 * The range ends at the selected commit and starts at its previous reachable release tag.
2222 * Throws if custom notes, the changelog configuration, or GitHub contributor detection are unavailable.
2323 * @param version Exact stable version being released.
24- * @returns Complete Markdown announcement, changelog, and new contributor section .
24+ * @returns Complete Markdown announcement and changelog, with acknowledgements when new contributors exist .
2525 */
2626export async function generateReleaseNotes ( version : string ) : Promise < string > {
2727 if ( ! / ^ \d + \. \d + \. \d + $ / . test ( version ) ) {
@@ -91,26 +91,32 @@ export async function generateReleaseNotes(version: string): Promise<string> {
9191 throw new Error ( 'GitHub did not return generated release notes.' )
9292 }
9393
94- return `${ announcement } \n\n---\n\n${ changelog . trim ( ) } \n\n${ contributorsSection ( githubNotes . body ) } \n`
94+ return `${ [
95+ announcement ,
96+ '---' ,
97+ changelog . trim ( ) ,
98+ contributorsSection ( githubNotes . body ) ,
99+ ]
100+ . filter ( Boolean )
101+ . join ( '\n\n' ) } \n`
95102}
96103
97104function contributorsSection ( notes : string ) : string {
98105 const lines = notes . split ( '\n' )
99106 const start = lines . findIndex ( ( line ) => / ^ # # N e w C o n t r i b u t o r s \s * $ / . test ( line ) )
100- if ( start === - 1 ) {
101- return '## New Contributors\n\nNo new contributors were detected for this release.'
102- }
107+ if ( start === - 1 ) return ''
103108
104109 const remaining = lines . slice ( start + 1 )
105110 const end = remaining . findIndex ( ( line ) =>
106111 / ^ # { 1 , 2 } | ^ \* \* F u l l C h a n g e l o g \* \* / . test ( line ) ,
107112 )
108- return [
109- '## New Contributors' ,
110- ...remaining . slice ( 0 , end === - 1 ? undefined : end ) ,
111- ]
113+ const contributors = remaining
114+ . slice ( 0 , end === - 1 ? undefined : end )
112115 . join ( '\n' )
113116 . trim ( )
117+ if ( ! contributors ) return ''
118+
119+ return `## New Contributors\n${ contributors } `
114120}
115121
116122function git ( ...args : string [ ] ) : string {
0 commit comments