chore: update release scripts to support sudowoodo (#14170)
Backports the totality of our release script changes to support sudowoodo. Also backports changes that have been made to a few other release script files in master after 3-0-x was cut with the purpose of keeping them in sync.
This commit is contained in:
parent
44b0245ac4
commit
2ecdf4a0eb
15 changed files with 272 additions and 104 deletions
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
if (!process.env.CI) require('dotenv-safe').load()
|
||||
require('colors')
|
||||
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')
|
||||
const fail = '\u2717'.red
|
||||
|
@ -15,13 +15,13 @@ const path = require('path')
|
|||
const pkg = require('../package.json')
|
||||
const readline = require('readline')
|
||||
const versionType = args._[0]
|
||||
const targetRepo = versionType === 'nightly' ? 'nightlies' : 'electron'
|
||||
|
||||
// TODO (future) automatically determine version based on conventional commits
|
||||
// via conventional-recommended-bump
|
||||
|
||||
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]` +
|
||||
console.log(`Usage: prepare-release versionType [stable | beta | nightly]` +
|
||||
` (--stable) (--notesOnly) (--automaticRelease) (--branch)`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
@ -30,10 +30,13 @@ const github = new GitHub()
|
|||
const gitDir = path.resolve(__dirname, '..')
|
||||
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
||||
|
||||
function getNewVersion (dryRun) {
|
||||
async function getNewVersion (dryRun) {
|
||||
console.log(`Bumping for new "${versionType}" version.`)
|
||||
let bumpScript = path.join(__dirname, 'bump-version.py')
|
||||
let scriptArgs = [bumpScript, `--bump ${versionType}`]
|
||||
let scriptArgs = [bumpScript]
|
||||
if (args.bump) {
|
||||
scriptArgs.push(`--bump ${versionType}`)
|
||||
}
|
||||
if (args.stable) {
|
||||
scriptArgs.push('--stable')
|
||||
}
|
||||
|
@ -50,6 +53,7 @@ function getNewVersion (dryRun) {
|
|||
return newVersion
|
||||
} catch (err) {
|
||||
console.log(`${fail} Could not bump version, error was:`, err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,10 +75,13 @@ async function getCurrentBranch (gitDir) {
|
|||
}
|
||||
|
||||
async function getReleaseNotes (currentBranch) {
|
||||
if (versionType === 'nightly') {
|
||||
return 'Nightlies do not get release notes, please compare tags for info'
|
||||
}
|
||||
console.log(`Generating release notes for ${currentBranch}.`)
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
repo: targetRepo,
|
||||
base: `v${pkg.version}`,
|
||||
head: currentBranch
|
||||
}
|
||||
|
@ -136,11 +143,11 @@ async function getReleaseNotes (currentBranch) {
|
|||
|
||||
async function createRelease (branchToTarget, isBeta) {
|
||||
let releaseNotes = await getReleaseNotes(branchToTarget)
|
||||
let newVersion = getNewVersion()
|
||||
let newVersion = await getNewVersion()
|
||||
await tagRelease(newVersion)
|
||||
const githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron'
|
||||
repo: targetRepo
|
||||
}
|
||||
console.log(`Checking for existing draft release.`)
|
||||
let releases = await github.repos.getReleases(githubOpts)
|
||||
|
@ -158,10 +165,17 @@ async function createRelease (branchToTarget, isBeta) {
|
|||
githubOpts.draft = true
|
||||
githubOpts.name = `electron ${newVersion}`
|
||||
if (isBeta) {
|
||||
githubOpts.body = `Note: This is a beta release. Please file new issues ` +
|
||||
`for any bugs you find in it.\n \n This release is published to npm ` +
|
||||
`under the beta tag and can be installed via npm install electron@beta, ` +
|
||||
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes}`
|
||||
if (newVersion.indexOf('nightly') > 0) {
|
||||
githubOpts.body = `Note: This is a nightly release. Please file new issues ` +
|
||||
`for any bugs you find in it.\n \n This release is published to npm ` +
|
||||
`under the nightly tag and can be installed via npm install electron@nightly, ` +
|
||||
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes}`
|
||||
} else {
|
||||
githubOpts.body = `Note: This is a beta release. Please file new issues ` +
|
||||
`for any bugs you find in it.\n \n This release is published to npm ` +
|
||||
`under the beta tag and can be installed via npm install electron@beta, ` +
|
||||
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes}`
|
||||
}
|
||||
githubOpts.name = `${githubOpts.name}`
|
||||
githubOpts.prerelease = true
|
||||
} else {
|
||||
|
@ -209,7 +223,7 @@ async function tagRelease (version) {
|
|||
}
|
||||
|
||||
async function verifyNewVersion () {
|
||||
let newVersion = getNewVersion(true)
|
||||
let newVersion = await getNewVersion(true)
|
||||
let response
|
||||
if (args.automaticRelease) {
|
||||
response = 'y'
|
||||
|
@ -239,8 +253,8 @@ async function promptForVersion (version) {
|
|||
|
||||
async function prepareRelease (isBeta, notesOnly) {
|
||||
if (args.automaticRelease && (pkg.version.indexOf('beta') === -1 ||
|
||||
versionType !== 'beta')) {
|
||||
console.log(`${fail} Automatic release is only supported for beta releases`)
|
||||
versionType !== 'beta') && versionType !== 'nightly' && versionType !== 'stable') {
|
||||
console.log(`${fail} Automatic release is only supported for beta and nightly releases`)
|
||||
process.exit(1)
|
||||
}
|
||||
let currentBranch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue