@@ -134,12 +134,9 @@ export default class ReleasePromotion extends Session {
134134
135135 // Set up for next release.
136136 cli . startSpinner ( 'Setting up for next release' ) ;
137- await this . setupForNextRelease ( ) ;
137+ const workingOnNewReleaseCommit = await this . setupForNextRelease ( ) ;
138138 cli . stopSpinner ( 'Successfully set up for next release' ) ;
139139
140- // Merge vX.Y.Z-proposal into vX.x.
141- await this . mergeProposalBranch ( ) ;
142-
143140 // Cherry pick release commit to master.
144141 const shouldCherryPick = await cli . prompt (
145142 'Cherry-pick release commit to the default branch?' , { defaultAnswer : true } ) ;
@@ -186,8 +183,8 @@ export default class ReleasePromotion extends Session {
186183 }
187184 }
188185
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 ) ;
191188
192189 // Promote and sign the release builds.
193190 await this . promoteAndSignRelease ( ) ;
@@ -385,56 +382,35 @@ export default class ReleasePromotion extends Session {
385382
386383 // Create 'Working On' commit.
387384 await forceRunAsync ( 'git' , [ 'add' , filePath ] , { ignoreFailure : false } ) ;
388- return forceRunAsync ( 'git' , [
385+ await forceRunAsync ( 'git' , [
389386 'commit' ,
390387 ...this . gpgSign ,
391388 '-m' ,
392389 `Working on ${ workingOnVersion } ` ,
393390 '-m' ,
394391 `PR-URL: https://github.com/nodejs/node/pull/${ prid } `
395392 ] , { ignoreFailure : false } ) ;
393+ return forceRunAsync ( 'git' , [ 'rev-parse' , 'HEAD' ] ,
394+ { ignoreFailure : false , captureStdout : true } ) ;
396395 }
397396
398- async mergeProposalBranch ( ) {
399- const { cli, dryRun, stagingBranch , versionComponents } = this ;
397+ async pushToRemote ( workingOnNewReleaseCommit ) {
398+ const { cli, dryRun, version , versionComponents, stagingBranch } = this ;
400399 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 ;
429400 const tagVersion = `v${ version } ` ;
430401
431402 this . defaultBranch ??= await this . getDefaultBranch ( ) ;
432403
433- let prompt = `Push release tag and ${ this . defaultBranch } to ${ this . upstream } ?` ;
404+ let prompt = `Push release tag and commits to ${ this . upstream } ?` ;
434405 if ( dryRun ) {
435406 cli . info ( dryRunMessage ) ;
436- cli . info ( 'Run the following commands to push to remote:' ) ;
437- cli . info ( `git push ${ this . upstream } ${ this . defaultBranch } ${ tagVersion } ` ) ;
407+ cli . info ( 'Run the following command to push to remote:' ) ;
408+ cli . info ( `git push ${ this . upstream } ${
409+ this . defaultBranch } ${
410+ tagVersion } ${
411+ workingOnNewReleaseCommit } :refs/heads/${ releaseBranch } ${
412+ workingOnNewReleaseCommit } :refs/heads/${ stagingBranch } `) ;
413+ cli . warn ( 'Once pushed, you must not delete the local tag' ) ;
438414 prompt = 'Ready to continue?' ;
439415 }
440416
@@ -447,9 +423,13 @@ export default class ReleasePromotion extends Session {
447423 }
448424
449425 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` ) ;
426+ await forceRunAsync ( 'git' , [ 'push' , this . upstream , this . defaultBranch , tagVersion ,
427+ `${ workingOnNewReleaseCommit } :refs/heads/${ releaseBranch } ` ,
428+ `${ workingOnNewReleaseCommit } :refs/heads/${ stagingBranch } ` ] ,
429+ { ignoreFailure : false } ) ;
430+ cli . stopSpinner ( `Pushed ${ tagVersion } , ${ this . defaultBranch } , ${
431+ releaseBranch } , and ${ stagingBranch } to remote`) ;
432+ cli . warn ( 'Now that it has been pushed, you must not delete the local tag' ) ;
453433 }
454434
455435 async promoteAndSignRelease ( ) {
0 commit comments