build: use semantic commits to get next version (#14851)

This commit is contained in:
Zach Bloomquist
2021-02-04 18:30:27 +00:00
committed by GitHub
parent aef9facd19
commit 0abb5efe90
12 changed files with 193 additions and 166 deletions

View File

@@ -3,7 +3,6 @@ let fs = require('fs-extra')
let glob = require('glob')
const Promise = require('bluebird')
const inquirer = require('inquirer')
const path = require('path')
glob = Promise.promisify(glob)
@@ -85,32 +84,6 @@ const getReleases = (releases) => {
}]
}
const getNextVersion = function ({ version } = {}) {
if (!version) {
({
version,
} = require(path.join(__dirname, '..', '..', 'package.json')))
}
const message = `Bump next version to...? (currently: ${version})`
const defaultVersion = function () {
const a = version.split('.')
let v = a[a.length - 1]
v = Number(v) + 1
a.splice(a.length - 1, 1, v)
return a.join('.')
}
return [{
name: 'nextVersion',
type: 'input',
message,
default: defaultVersion,
}]
}
const getVersions = (releases) => {
return [{
name: 'version',
@@ -213,11 +186,6 @@ const whichBumpTask = () => {
.get('task')
}
const nextVersion = (version) => {
return prompt(getNextVersion(version))
.get('nextVersion')
}
const toCommit = ({ version }) => {
return prompt(getCommitVersion(version))
.get('commit')
@@ -232,11 +200,9 @@ module.exports = {
getVersions,
getBumpTasks,
deployNewVersion,
nextVersion,
whichZipFile,
whichVersion,
whichRelease,
whichPlatform,
whichBumpTask,
}

View File

@@ -69,19 +69,6 @@ const remapProjects = function (projectsByProvider) {
return list
}
const remapMain = function (projectsByProvider) {
const list = []
_.mapValues(projectsByProvider, (provider, name) => {
return list.push({
repo: provider.main,
provider: name,
})
})
return list
}
// make flat list of objects
// {repo, provider, platform}
const PROJECTS = remapProjects(_PROVIDERS)
@@ -178,28 +165,6 @@ module.exports = {
getFilterByProvider,
nextVersion (version) {
const MAIN_PROJECTS = remapMain(_PROVIDERS)
console.log('Setting next version to build', version)
console.log('In these projects:')
console.table(MAIN_PROJECTS)
la(check.unemptyString(version),
'missing next version to set', version)
const setNextDevVersion = function (project, provider) {
console.log('setting env var NEXT_DEV_VERSION to %s on %s in project %s',
version, provider, project)
return car.updateProjectEnv(project, provider, {
NEXT_DEV_VERSION: version,
})
}
return awaitEachProjectAndProvider(MAIN_PROJECTS, setNextDevVersion)
},
// in each project, set a couple of environment variables
version (nameOrUrl, binaryVersionOrUrl, platform, providerName) {
console.log('All possible projects:')

View File

@@ -47,7 +47,6 @@ const askMissingOptions = function (properties = []) {
version: ask.deployNewVersion,
// note: zip file might not be absolute
zip: ask.whichZipFile,
nextVersion: ask.nextVersion,
commit: ask.toCommit,
}
const pickedQuestions = _.pick(questions, properties)
@@ -128,29 +127,16 @@ const deploy = {
})
},
// sets environment variable on each CI provider
// to NEXT version to build
setNextVersion () {
const options = this.parseOptions(process.argv)
return askMissingOptions(['nextVersion'])(options)
.then(({ nextVersion }) => {
return bump.nextVersion(nextVersion)
})
},
release () {
// read off the argv
const options = this.parseOptions(process.argv)
const release = ({ version, commit, nextVersion }) => {
const release = ({ version, commit }) => {
return upload.s3Manifest(version)
.then(() => {
if (commit) {
return commitVersion(version)
}
}).then(() => {
return bump.nextVersion(nextVersion)
}).then(() => {
return success('Release Complete')
}).catch((err) => {
@@ -159,7 +145,7 @@ const deploy = {
})
}
return askMissingOptions(['version', 'nextVersion'])(options)
return askMissingOptions(['version'])(options)
.then(release)
},