@@ -62,6 +62,10 @@ yargs(process.argv.slice(2))
6262 choices : semverChoices ,
6363 default : "patch" ,
6464 } )
65+ . option ( "reviewers" , {
66+ describe : "Comma-separated list of users to request reviews from" ,
67+ nargs : 1 ,
68+ } )
6569 . demandOption ( "semverlevel" , "You must provide a semver level" ) ;
6670 } ,
6771 handler : init ,
@@ -87,6 +91,10 @@ function init(args) {
8791 logger . debug ( checkoutCmd ) ;
8892 execSync ( checkoutCmd ) ;
8993
94+ const { version : previousVersion } = readPackageJSON (
95+ packages [ "web-features" ] ,
96+ ) ;
97+
9098 // Bump version (no tag)
9199 const newVersion = bumpVersion ( args . semverlevel ) ;
92100
@@ -98,13 +106,13 @@ function init(args) {
98106 // Create PR
99107 const title = [ pullTitleBase , newVersion ] . join ( "" ) ;
100108 logger . info ( `Creating PR: ${ title } ` ) ;
101- const reviewer = "ddbeck" ;
102- const body = makePullBody ( diff ) ;
109+ const reviewers = args . reviewers . split ( "," ) ;
110+ const body = makePullBody ( newVersion , previousVersion ) ;
103111
104112 const pullRequestCmd = [
105113 "gh pr create" ,
106114 `--title="${ title } "` ,
107- `--reviewer=" ${ reviewer } "` ,
115+ ... reviewers . map ( ( r ) => `--reviewer=${ r } ` ) ,
108116 `--body-file=-` ,
109117 `--base="main"` ,
110118 `--head="${ releaseBranch } "` ,
@@ -132,15 +140,31 @@ function bumpVersion(semverlevel: typeof semverChoices): string {
132140 return version ;
133141}
134142
135- function makePullBody ( diff : string ) {
143+ function makePullBody ( newVersion : string , previousVersion : string ) {
144+ // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release
145+ const relnotesCmd = [
146+ "gh" ,
147+ "api" ,
148+ "--method POST" ,
149+ `-H "Accept: application/vnd.github+json"` ,
150+ `-H "X-GitHub-Api-Version: 2022-11-28"` ,
151+ "/repos/{owner}/{repo}/releases/generate-notes" ,
152+ `-f "tag_name=v${ newVersion } "` ,
153+ `-f "target_commitish=main"` ,
154+ `-f "previous_tag_name=v${ previousVersion } "` ,
155+ ] . join ( " " ) ;
156+ const relNotes = execSync ( relnotesCmd , {
157+ cwd : packages [ "web-features" ] ,
158+ encoding : "utf-8" ,
159+ } ) ;
160+ const relNotesLines = JSON . parse ( relNotes ) . body . split ( "\n" ) ;
161+
136162 const bodyFile = fileURLToPath (
137163 new URL ( "release-pull-description.md" , import . meta. url ) ,
138164 ) ;
139165 const body = [
140166 readFileSync ( bodyFile , { encoding : "utf-8" } ) ,
141- "```diff" ,
142- diff ,
143- "```" ,
167+ ...relNotesLines ,
144168 ] . join ( "\n" ) ;
145169 return body ;
146170}
0 commit comments