@@ -86,33 +86,13 @@ export class GitHubReleaser implements Releaser {
8686 body : string ;
8787 } ;
8888 } > {
89- const response = await this . github . rest . repos . generateReleaseNotes ( params ) ;
89+ return await this . github . rest . repos . generateReleaseNotes ( params ) ;
90+ }
91+
92+ truncateReleaseNotes ( input : string ) : string {
9093 // release notes can be a maximum of 125000 characters
91- const noteSections = response . data . body ?. split ( '\n\n' ) ;
92- const trimmedSections : string [ ] = [ ] ;
9394 const githubNotesMaxCharLength = 125000 ;
94- const maxSectionLength = githubNotesMaxCharLength / noteSections . length ;
95- for ( let i = 0 ; i < noteSections . length ; i ++ ) {
96- if ( noteSections [ i ] . length > githubNotesMaxCharLength ) {
97- const lastLineIndex = noteSections [ i ] . substring ( 0 , maxSectionLength ) . split ( '\n' ) . length - 1 ;
98- const trimmed =
99- noteSections [ i ]
100- . split ( '\n' )
101- . slice ( 0 , lastLineIndex - 1 )
102- . join ( '\n' ) +
103- `\n... (+${ noteSections [ i ] . split ( '\n' ) . length - ( lastLineIndex + 1 ) } others)` ;
104- trimmedSections . push ( trimmed ) ;
105- continue ;
106- }
107-
108- trimmedSections . push ( noteSections [ i ] ) ;
109- }
110- return {
111- data : {
112- name : response . data . name ,
113- body : trimmedSections . join ( '\n\n' ) ,
114- } ,
115- } ;
95+ return input . substring ( 0 , githubNotesMaxCharLength - 1 ) ;
11696 }
11797
11898 async createRelease ( params : {
@@ -143,6 +123,7 @@ export class GitHubReleaser implements Releaser {
143123 params . body = releaseNotes . data . body ;
144124 }
145125 }
126+ params . body = params . body ? this . truncateReleaseNotes ( params . body ) : undefined ;
146127 return this . github . rest . repos . createRelease ( params ) ;
147128 }
148129
@@ -175,6 +156,7 @@ export class GitHubReleaser implements Releaser {
175156 params . body = releaseNotes . data . body ;
176157 }
177158 }
159+ params . body = params . body ? this . truncateReleaseNotes ( params . body ) : undefined ;
178160 return this . github . rest . repos . updateRelease ( params ) ;
179161 }
180162
0 commit comments