@@ -134,12 +134,9 @@ export default class ReleasePromotion extends Session {
134
134
135
135
// Set up for next release.
136
136
cli . startSpinner ( 'Setting up for next release' ) ;
137
- await this . setupForNextRelease ( ) ;
137
+ const workingOnNewReleaseCommit = await this . setupForNextRelease ( ) ;
138
138
cli . stopSpinner ( 'Successfully set up for next release' ) ;
139
139
140
- // Merge vX.Y.Z-proposal into vX.x.
141
- await this . mergeProposalBranch ( ) ;
142
-
143
140
// Cherry pick release commit to master.
144
141
const shouldCherryPick = await cli . prompt (
145
142
'Cherry-pick release commit to the default branch?' , { defaultAnswer : true } ) ;
@@ -186,8 +183,8 @@ export default class ReleasePromotion extends Session {
186
183
}
187
184
}
188
185
189
- // Push to the remote default branch and release tag .
190
- await this . pushTagAndDefaultBranchToRemote ( ) ;
186
+ // Push to the remote the release tag, and default, release, and staging branch .
187
+ await this . pushToRemote ( workingOnNewReleaseCommit ) ;
191
188
192
189
// Promote and sign the release builds.
193
190
await this . promoteAndSignRelease ( ) ;
@@ -385,56 +382,36 @@ export default class ReleasePromotion extends Session {
385
382
386
383
// Create 'Working On' commit.
387
384
await forceRunAsync ( 'git' , [ 'add' , filePath ] , { ignoreFailure : false } ) ;
388
- return forceRunAsync ( 'git' , [
385
+ await forceRunAsync ( 'git' , [
389
386
'commit' ,
390
387
...this . gpgSign ,
391
388
'-m' ,
392
389
`Working on ${ workingOnVersion } ` ,
393
390
'-m' ,
394
391
`PR-URL: https://github.com/nodejs/node/pull/${ prid } `
395
392
] , { ignoreFailure : false } ) ;
393
+ const workingOnNewReleaseCommit = await forceRunAsync ( 'git' , [ 'rev-parse' , 'HEAD' ] ,
394
+ { ignoreFailure : false , captureStdout : true } ) ;
395
+ return workingOnNewReleaseCommit . trim ( ) ;
396
396
}
397
397
398
- async mergeProposalBranch ( ) {
399
- const { cli, dryRun, stagingBranch , versionComponents } = this ;
398
+ async pushToRemote ( workingOnNewReleaseCommit ) {
399
+ const { cli, dryRun, version , versionComponents, stagingBranch } = this ;
400
400
const releaseBranch = `v${ versionComponents . major } .x` ;
401
-
402
- let prompt = 'Merge proposal branch into staging branch?' ;
403
- if ( dryRun ) {
404
- cli . info ( dryRunMessage ) ;
405
- cli . info ( 'Run the following commands to merge the staging branch:' ) ;
406
- cli . info ( `git push ${ this . upstream } HEAD:refs/heads/${ releaseBranch
407
- } HEAD:refs/heads/${ stagingBranch } `) ;
408
- prompt = 'Ready to continue?' ;
409
- }
410
-
411
- const shouldMergeProposalBranch = await cli . prompt ( prompt , { defaultAnswer : true } ) ;
412
- if ( ! shouldMergeProposalBranch ) {
413
- cli . warn ( 'Aborting release promotion' ) ;
414
- throw new Error ( 'Aborted' ) ;
415
- } else if ( dryRun ) {
416
- return ;
417
- }
418
-
419
- // TODO: find a solution for key passphrase from the terminal
420
- cli . startSpinner ( 'Merging proposal branch' ) ;
421
- await forceRunAsync ( 'git' , [ 'push' , this . upstream , `HEAD:refs/heads/${ releaseBranch } ` ,
422
- `HEAD:refs/heads/${ stagingBranch } ` ] ,
423
- { ignoreFailure : false } ) ;
424
- cli . stopSpinner ( 'Merged proposal branch' ) ;
425
- }
426
-
427
- async pushTagAndDefaultBranchToRemote ( ) {
428
- const { cli, dryRun, version } = this ;
429
401
const tagVersion = `v${ version } ` ;
430
402
431
403
this . defaultBranch ??= await this . getDefaultBranch ( ) ;
432
404
433
- let prompt = `Push release tag and ${ this . defaultBranch } to ${ this . upstream } ?` ;
405
+ let prompt = `Push release tag and commits to ${ this . upstream } ?` ;
434
406
if ( dryRun ) {
435
407
cli . info ( dryRunMessage ) ;
436
- cli . info ( 'Run the following commands to push to remote:' ) ;
437
- cli . info ( `git push ${ this . upstream } ${ this . defaultBranch } ${ tagVersion } ` ) ;
408
+ cli . info ( 'Run the following command to push to remote:' ) ;
409
+ cli . info ( `git push ${ this . upstream } ${
410
+ this . defaultBranch } ${
411
+ tagVersion } ${
412
+ workingOnNewReleaseCommit } :refs/heads/${ releaseBranch } ${
413
+ workingOnNewReleaseCommit } :refs/heads/${ stagingBranch } `) ;
414
+ cli . warn ( 'Once pushed, you must not delete the local tag' ) ;
438
415
prompt = 'Ready to continue?' ;
439
416
}
440
417
@@ -447,9 +424,13 @@ export default class ReleasePromotion extends Session {
447
424
}
448
425
449
426
cli . startSpinner ( 'Pushing to remote' ) ;
450
- await forceRunAsync ( 'git' , [ 'push' , this . upstream , this . defaultBranch , tagVersion ] ,
451
- { ignoreFailure : false } ) ;
452
- cli . stopSpinner ( `Pushed ${ tagVersion } and ${ this . defaultBranch } to remote` ) ;
427
+ await forceRunAsync ( 'git' , [ 'push' , this . upstream , this . defaultBranch , tagVersion ,
428
+ `${ workingOnNewReleaseCommit } :refs/heads/${ releaseBranch } ` ,
429
+ `${ workingOnNewReleaseCommit } :refs/heads/${ stagingBranch } ` ] ,
430
+ { ignoreFailure : false } ) ;
431
+ cli . stopSpinner ( `Pushed ${ tagVersion } , ${ this . defaultBranch } , ${
432
+ releaseBranch } , and ${ stagingBranch } to remote`) ;
433
+ cli . warn ( 'Now that it has been pushed, you must not delete the local tag' ) ;
453
434
}
454
435
455
436
async promoteAndSignRelease ( ) {
0 commit comments