Release updates in prep for 3-0-x releases (#12916)
* Add autorelease logic * Fix UnboundLocalError when using s3 upload
This commit is contained in:
parent
d5dfb19508
commit
cc2cd95ec5
4 changed files with 110 additions and 33 deletions
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
require('colors')
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
const args = require('minimist')(process.argv.slice(2), {
|
||||
boolean: ['automaticRelease', 'notesOnly', 'stable']
|
||||
})
|
||||
const assert = require('assert')
|
||||
const ciReleaseBuild = require('./ci-release-build')
|
||||
const { execSync } = require('child_process')
|
||||
|
@ -20,7 +22,7 @@ const versionType = args._[0]
|
|||
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
||||
if (!versionType && !args.notesOnly) {
|
||||
console.log(`Usage: prepare-release versionType [major | minor | patch | beta]` +
|
||||
` (--stable) (--notesOnly)`)
|
||||
` (--stable) (--notesOnly) (--automaticRelease) (--branch)`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
|
@ -76,7 +78,12 @@ async function getReleaseNotes (currentBranch) {
|
|||
base: `v${pkg.version}`,
|
||||
head: currentBranch
|
||||
}
|
||||
let releaseNotes = '(placeholder)\n'
|
||||
let releaseNotes
|
||||
if (args.automaticRelease) {
|
||||
releaseNotes = '## Bug Fixes/Changes \n\n'
|
||||
} else {
|
||||
releaseNotes = '(placeholder)\n'
|
||||
}
|
||||
console.log(`Checking for commits from ${pkg.version} to ${currentBranch}`)
|
||||
let commitComparison = await github.repos.compareCommits(githubOpts)
|
||||
.catch(err => {
|
||||
|
@ -85,13 +92,45 @@ async function getReleaseNotes (currentBranch) {
|
|||
process.exit(1)
|
||||
})
|
||||
|
||||
if (commitComparison.data.commits.length === 0) {
|
||||
console.log(`${pass} There are no commits from ${pkg.version} to ` +
|
||||
`${currentBranch}, skipping release.`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
let prCount = 0
|
||||
const mergeRE = /Merge pull request #(\d+) from .*\n/
|
||||
const newlineRE = /(.*)\n*.*/
|
||||
const prRE = /(.* )\(#(\d+)\)(?:.*)/
|
||||
commitComparison.data.commits.forEach(commitEntry => {
|
||||
let commitMessage = commitEntry.commit.message
|
||||
if (commitMessage.toLowerCase().indexOf('merge') > -1) {
|
||||
releaseNotes += `${commitMessage} \n`
|
||||
if (commitMessage.indexOf('#') > -1) {
|
||||
let prMatch = commitMessage.match(mergeRE)
|
||||
let prNumber
|
||||
if (prMatch) {
|
||||
commitMessage = commitMessage.replace(mergeRE, '').replace('\n', '')
|
||||
let newlineMatch = commitMessage.match(newlineRE)
|
||||
if (newlineMatch) {
|
||||
commitMessage = newlineMatch[1]
|
||||
}
|
||||
prNumber = prMatch[1]
|
||||
} else {
|
||||
prMatch = commitMessage.match(prRE)
|
||||
if (prMatch) {
|
||||
commitMessage = prMatch[1].trim()
|
||||
prNumber = prMatch[2]
|
||||
}
|
||||
}
|
||||
if (prMatch) {
|
||||
if (commitMessage.substr(commitMessage.length - 1, commitMessage.length) !== '.') {
|
||||
commitMessage += '.'
|
||||
}
|
||||
releaseNotes += `* ${commitMessage} #${prNumber} \n\n`
|
||||
prCount++
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(`${pass} Done generating release notes for ${currentBranch}.`)
|
||||
console.log(`${pass} Done generating release notes for ${currentBranch}. Found ${prCount} PRs.`)
|
||||
return releaseNotes
|
||||
}
|
||||
|
||||
|
@ -138,8 +177,8 @@ async function createRelease (branchToTarget, isBeta) {
|
|||
console.log(`${pass} Draft release for ${newVersion} has been created.`)
|
||||
}
|
||||
|
||||
async function pushRelease () {
|
||||
let pushDetails = await GitProcess.exec(['push', 'origin', 'HEAD', '--follow-tags'], gitDir)
|
||||
async function pushRelease (branch) {
|
||||
let pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], gitDir)
|
||||
if (pushDetails.exitCode === 0) {
|
||||
console.log(`${pass} Successfully pushed the release. Wait for ` +
|
||||
`release builds to finish before running "npm run release".`)
|
||||
|
@ -152,7 +191,8 @@ async function pushRelease () {
|
|||
|
||||
async function runReleaseBuilds (branch) {
|
||||
await ciReleaseBuild(branch, {
|
||||
ghRelease: true
|
||||
ghRelease: true,
|
||||
automaticRelease: args.automaticRelease
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -170,7 +210,12 @@ async function tagRelease (version) {
|
|||
|
||||
async function verifyNewVersion () {
|
||||
let newVersion = getNewVersion(true)
|
||||
let response = await promptForVersion(newVersion)
|
||||
let response
|
||||
if (args.automaticRelease) {
|
||||
response = 'y'
|
||||
} else {
|
||||
response = await promptForVersion(newVersion)
|
||||
}
|
||||
if (response.match(/^y/i)) {
|
||||
console.log(`${pass} Starting release of ${newVersion}`)
|
||||
} else {
|
||||
|
@ -193,14 +238,24 @@ async function promptForVersion (version) {
|
|||
}
|
||||
|
||||
async function prepareRelease (isBeta, notesOnly) {
|
||||
let currentBranch = await getCurrentBranch(gitDir)
|
||||
if (args.automaticRelease && (pkg.version.indexOf('beta') === -1 ||
|
||||
versionType !== 'beta')) {
|
||||
console.log(`${fail} Automatic release is only supported for beta releases`)
|
||||
process.exit(1)
|
||||
}
|
||||
let currentBranch
|
||||
if (args.branch) {
|
||||
currentBranch = args.branch
|
||||
} else {
|
||||
currentBranch = await getCurrentBranch(gitDir)
|
||||
}
|
||||
if (notesOnly) {
|
||||
let releaseNotes = await getReleaseNotes(currentBranch)
|
||||
console.log(`Draft release notes are: ${releaseNotes}`)
|
||||
console.log(`Draft release notes are: \n${releaseNotes}`)
|
||||
} else {
|
||||
await verifyNewVersion()
|
||||
await createRelease(currentBranch, isBeta)
|
||||
await pushRelease()
|
||||
await pushRelease(currentBranch)
|
||||
await runReleaseBuilds(currentBranch)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue