@@ -6,7 +6,7 @@ const assert = require('assert')
66const ciReleaseBuild = require ( './ci-release-build' )
77const { execSync } = require ( 'child_process' )
88const fail = '\u2717' . red
9- const { GitProcess, GitError } = require ( 'dugite' )
9+ const { GitProcess } = require ( 'dugite' )
1010const GitHub = require ( 'github' )
1111const pass = '\u2713' . green
1212const path = require ( 'path' )
@@ -28,24 +28,6 @@ const github = new GitHub()
2828const gitDir = path . resolve ( __dirname , '..' )
2929github . authenticate ( { type : 'token' , token : process . env . ELECTRON_GITHUB_TOKEN } )
3030
31- async function createReleaseBranch ( ) {
32- console . log ( `Creating release branch.` )
33- let checkoutDetails = await GitProcess . exec ( [ 'checkout' , '-b' , 'release' ] , gitDir )
34- if ( checkoutDetails . exitCode === 0 ) {
35- console . log ( `${ pass } Successfully created the release branch.` )
36- } else {
37- const error = GitProcess . parseError ( checkoutDetails . stderr )
38- if ( error === GitError . BranchAlreadyExists ) {
39- console . log ( `${ fail } Release branch already exists, aborting prepare ` +
40- `release process.` )
41- } else {
42- console . log ( `${ fail } Error creating release branch: ` +
43- `${ checkoutDetails . stderr } ` )
44- }
45- process . exit ( 1 )
46- }
47- }
48-
4931function getNewVersion ( dryRun ) {
5032 console . log ( `Bumping for new "${ versionType } " version.` )
5133 let bumpScript = path . join ( __dirname , 'bump-version.py' )
@@ -98,7 +80,7 @@ async function getReleaseNotes (currentBranch) {
9880 console . log ( `Checking for commits from ${ pkg . version } to ${ currentBranch } ` )
9981 let commitComparison = await github . repos . compareCommits ( githubOpts )
10082 . catch ( err => {
101- console . log ( `{$ fail} Error checking for commits from ${ pkg . version } to ` +
83+ console . log ( `${ fail } Error checking for commits from ${ pkg . version } to ` +
10284 `${ currentBranch } ` , err )
10385 process . exit ( 1 )
10486 } )
@@ -116,6 +98,7 @@ async function getReleaseNotes (currentBranch) {
11698async function createRelease ( branchToTarget , isBeta ) {
11799 let releaseNotes = await getReleaseNotes ( branchToTarget )
118100 let newVersion = getNewVersion ( )
101+ await tagRelease ( newVersion )
119102 const githubOpts = {
120103 owner : 'electron' ,
121104 repo : 'electron'
@@ -156,25 +139,37 @@ async function createRelease (branchToTarget, isBeta) {
156139}
157140
158141async function pushRelease ( ) {
159- let pushDetails = await GitProcess . exec ( [ 'push' , 'origin' , 'HEAD' ] , gitDir )
142+ let pushDetails = await GitProcess . exec ( [ 'push' , 'origin' , 'HEAD' , '--follow-tags' ] , gitDir )
160143 if ( pushDetails . exitCode === 0 ) {
161- console . log ( `${ pass } Successfully pushed the release branch . Wait for ` +
144+ console . log ( `${ pass } Successfully pushed the release. Wait for ` +
162145 `release builds to finish before running "npm run release".` )
163146 } else {
164- console . log ( `${ fail } Error pushing the release branch : ` +
147+ console . log ( `${ fail } Error pushing the release: ` +
165148 `${ pushDetails . stderr } ` )
166149 process . exit ( 1 )
167150 }
168151}
169152
170- async function runReleaseBuilds ( ) {
171- await ciReleaseBuild ( 'release' , {
153+ async function runReleaseBuilds ( branch ) {
154+ await ciReleaseBuild ( branch , {
172155 ghRelease : true
173156 } )
174157}
175158
159+ async function tagRelease ( version ) {
160+ console . log ( `Tagging release ${ version } .` )
161+ let checkoutDetails = await GitProcess . exec ( [ 'tag' , '-a' , '-m' , version , version ] , gitDir )
162+ if ( checkoutDetails . exitCode === 0 ) {
163+ console . log ( `${ pass } Successfully tagged ${ version } .` )
164+ } else {
165+ console . log ( `${ fail } Error tagging ${ version } : ` +
166+ `${ checkoutDetails . stderr } ` )
167+ process . exit ( 1 )
168+ }
169+ }
170+
176171async function verifyNewVersion ( ) {
177- let newVersion = await getNewVersion ( true )
172+ let newVersion = getNewVersion ( true )
178173 let response = await promptForVersion ( newVersion )
179174 if ( response . match ( / ^ y / i) ) {
180175 console . log ( `${ pass } Starting release of ${ newVersion } ` )
@@ -204,10 +199,9 @@ async function prepareRelease (isBeta, notesOnly) {
204199 console . log ( `Draft release notes are: ${ releaseNotes } ` )
205200 } else {
206201 await verifyNewVersion ( )
207- await createReleaseBranch ( )
208202 await createRelease ( currentBranch , isBeta )
209203 await pushRelease ( )
210- await runReleaseBuilds ( )
204+ await runReleaseBuilds ( currentBranch )
211205 }
212206}
213207
0 commit comments