mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-26 10:59:23 -06:00
build: use semantic commits to get next version (#14851)
This commit is contained in:
@@ -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,
|
||||
|
||||
}
|
||||
|
||||
@@ -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:')
|
||||
|
||||
@@ -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)
|
||||
},
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
if (!process.env.NEXT_DEV_VERSION) {
|
||||
console.log('NEXT_DEV_VERSION is not set')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const currentVersion = require('../package.json').version
|
||||
|
||||
if (currentVersion === process.env.NEXT_DEV_VERSION) {
|
||||
console.warn('⚠️ NEXT_DEV_VERSION is set to the same value as current package.json version "%s"', currentVersion)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
console.log('NEXT_DEV_VERSION is different from the current package version "%s"', currentVersion)
|
||||
29
scripts/get-next-version.js
Normal file
29
scripts/get-next-version.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const semver = require('semver')
|
||||
|
||||
const fail = (...reason) => {
|
||||
console.error(...reason)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const bump = require('conventional-recommended-bump')
|
||||
const currentVersion = require('../package.json').version
|
||||
|
||||
bump({ preset: 'angular' }, (err, { releaseType }) => {
|
||||
if (err) {
|
||||
return fail('Error getting next version', err)
|
||||
}
|
||||
|
||||
const nextVersion = semver.inc(currentVersion, releaseType || 'patch')
|
||||
|
||||
if (process.argv.includes('--npm')) {
|
||||
const cmd = `npm --no-git-tag-version version ${nextVersion}`
|
||||
|
||||
console.log(`Running '${cmd}'...`)
|
||||
|
||||
return require('child_process').execSync(cmd)
|
||||
}
|
||||
|
||||
console.log(nextVersion)
|
||||
})
|
||||
@@ -8,9 +8,8 @@
|
||||
|
||||
const shell = require('shelljs')
|
||||
const os = require('os')
|
||||
const la = require('lazy-ass')
|
||||
const is = require('check-more-types')
|
||||
// const assert = require('assert')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
shell.set('-v') // verbose
|
||||
shell.set('-e') // any error is fatal
|
||||
@@ -26,7 +25,7 @@ const isRightBranch = () => {
|
||||
process.env.APPVEYOR_REPO_COMMIT_MESSAGE || ''
|
||||
).includes('[build binary]')
|
||||
|
||||
const branchesToBuildBinary = ['develop', 'revert-create-cypress-tests']
|
||||
const branchesToBuildBinary = ['develop', 'sem-next-ver']
|
||||
|
||||
return branchesToBuildBinary.includes(branch) || shouldForceBinaryBuild
|
||||
}
|
||||
@@ -47,11 +46,10 @@ if (!shouldBuildBinary()) {
|
||||
}
|
||||
|
||||
console.log('building Windows binary')
|
||||
|
||||
const filename = `cypress-v${process.env.NEXT_DEV_VERSION}.tgz`
|
||||
const version = process.env.NEXT_DEV_VERSION
|
||||
|
||||
la(is.unemptyString(version), 'missing NEXT_DEV_VERSION')
|
||||
const pkgPath = path.join(__dirname, '../package.json')
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath).toString())
|
||||
const { version } = pkg
|
||||
const filename = `cypress-v${version}.tgz`
|
||||
|
||||
console.log('building version', version)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user