root: add additional tasks for committing release and updating repos with next dev version

This commit is contained in:
Brian Mann
2017-10-14 19:55:29 -04:00
parent 6ef0625b59
commit 5c007badfe
4 changed files with 122 additions and 37 deletions

View File

@@ -74,6 +74,19 @@ getReleases = (releases) ->
}
}]
getNextVersion = ({ version }) ->
[{
name: "nextVersion"
type: "input"
message: "Bump next version to...? (currently: #{version})"
default: ->
a = version.split(".")
v = a[a.length - 1]
v = Number(v) + 1
a.splice(a.length - 1, 1, v)
a.join(".")
}]
getVersions = (releases) ->
[{
name: "version"
@@ -100,6 +113,20 @@ getBumpTasks = ->
}]
}]
getCommitVersion = (version) ->
[{
name: "commit"
type: "list"
message: "Commit this new version to git? (currently: #{version})"
choices: [{
name: "Yes: commit and push this new release version."
value: true
},{
name: "No: do not commit."
value: false
}]
}]
deployNewVersion = ->
fs.readJsonAsync("./package.json")
.then (json) =>
@@ -149,7 +176,16 @@ whichBumpTask = ->
prompt(getBumpTasks())
.get("task")
nextVersion = (version) ->
prompt(getNextVersion(version))
.get("nextVersion")
toCommit = ({ version }) ->
prompt(getCommitVersion(version))
.get("commit")
module.exports = {
toCommit
getZipFile
getPlatformQuestion
getQuestions
@@ -157,6 +193,7 @@ module.exports = {
getVersions
getBumpTasks
deployNewVersion
nextVersion
whichZipFile
whichVersion
whichRelease

View File

@@ -17,29 +17,35 @@ car = null
# all the projects to trigger / run / change environment variables for
_PROVIDERS = {
appVeyor: [
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-example-repos"
# "cypress-io/cypress-example-kitchensink"
# "cypress-io/cypress-example-todomvc"
]
appVeyor: {
main: "cypress-io/cypress"
others: [
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-example-repos"
# "cypress-io/cypress-example-kitchensink"
# "cypress-io/cypress-example-todomvc"
]
}
circle: [
# "cypress-io/cypress-dashboard"
# "cypress-io/cypress-core-example"
# "cypress-io/cypress-core-desktop-gui"
# "cypress-io/cypress-example-kitchensink"
# "cypress-io/cypress-example-todomvc"
# "cypress-io/cypress-example-piechopper"
# "cypress-io/cypress-example-recipes"
circle: {
main: "cypress-io/cypress"
others: [
# "cypress-io/cypress-dashboard"
# "cypress-io/cypress-core-example"
# "cypress-io/cypress-core-desktop-gui"
# "cypress-io/cypress-example-kitchensink"
# "cypress-io/cypress-example-todomvc"
# "cypress-io/cypress-example-piechopper"
# "cypress-io/cypress-example-recipes"
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-module-api"
"cypress-io/cypress-test-node-versions"
"cypress-io/cypress-test-nested-projects"
"cypress-io/cypress-test-ci-environments"
"cypress-io/cypress-test-example-repos"
]
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-module-api"
"cypress-io/cypress-test-node-versions"
"cypress-io/cypress-test-nested-projects"
"cypress-io/cypress-test-ci-environments"
"cypress-io/cypress-test-example-repos"
]
}
# travis: [
# # "cypress-io/cypress-dashboard"
@@ -53,20 +59,32 @@ _PROVIDERS = {
}
remapProjects = (projectsByProvider) ->
# could also be remap + flatten
list = []
addToList = (projects, provider) ->
projects.forEach (repo) ->
_.mapValues projectsByProvider, (provider, name) ->
provider.others.forEach (repo) ->
list.push({
repo,
provider
repo
provider: name
})
R.mapObjIndexed(addToList, projectsByProvider)
list
remapMain = (projectsByProvider) ->
list = []
_.mapValues projectsByProvider, (provider, name) ->
list.push({
repo: provider.main
provider: name
})
list
# make flat list of objects
# {repo, provider}
PROJECTS = remapProjects(_PROVIDERS)
MAIN_PROJECTS = remapMain(_PROVIDERS)
getCiConfig = ->
## gleb: fix this plzzzzzz
@@ -88,7 +106,7 @@ getCiConfig = ->
throw new Error('CI config not found')
config
awaitEachProjectAndProvider = (fn, filter = R.identity) ->
awaitEachProjectAndProvider = (projects, fn, filter = R.identity) ->
creds = getCiConfig()
# TODO only check tokens for providers we really going to use
la(check.unemptyString(creds.githubToken), "missing githubToken")
@@ -110,7 +128,7 @@ awaitEachProjectAndProvider = (fn, filter = R.identity) ->
}
})
filteredProjects = R.filter(filter, PROJECTS)
filteredProjects = R.filter(filter, projects)
if check.empty(filteredProjects)
console.log("⚠️ zero filtered projects left after filtering")
console.table("filtered projects", filteredProjects)
@@ -128,6 +146,20 @@ getFilterByProvider = (providerName) ->
projectFilter
module.exports = {
nextVersion: (version) ->
console.table("All possible projects", MAIN_PROJECTS)
la(check.unemptyString(version),
"missing next version to set", version)
updateProject = (project, provider) ->
console.log("setting environment variables in", project)
car.updateProjectEnv(project, provider, {
NEXT_DEV_VERSION: version,
})
awaitEachProjectAndProvider(MAIN_PROJECTS, updateProject)
# in each project, set a couple of environment variables
version: (nameOrUrl, binaryVersionOrUrl, platform, providerName) ->
console.table("All possible projects", PROJECTS)
@@ -156,7 +188,7 @@ module.exports = {
CYPRESS_NPM_PACKAGE_NAME: nameOrUrl,
CYPRESS_BINARY_VERSION: binaryVersionOrUrl
})
awaitEachProjectAndProvider(updateProject, projectFilter)
awaitEachProjectAndProvider(PROJECTS, updateProject, projectFilter)
.then R.always(result)
run: (message, providerName) ->
@@ -191,5 +223,5 @@ module.exports = {
token: creds.githubToken,
message
})
awaitEachProjectAndProvider(makeCommit, projectFilter)
awaitEachProjectAndProvider(PROJECTS, makeCommit, projectFilter)
}

View File

@@ -4,6 +4,7 @@ cwd = process.cwd()
path = require("path")
_ = require("lodash")
os = require("os")
gift = require("gift")
chalk = require("chalk")
Promise = require("bluebird")
minimist = require("minimist")
@@ -23,6 +24,9 @@ uploadUtils = require("./util/upload")
{uploadNpmPackage} = require("./upload-npm-package")
{uploadUniqueBinary} = require("./upload-unique-binary")
## initialize on existing repo
repo = Promise.promisifyAll(gift(cwd))
success = (str) ->
console.log chalk.bgGreen(" " + chalk.black(str) + " ")
@@ -40,12 +44,21 @@ askMissingOptions = (properties = []) ->
version: ask.deployNewVersion,
# note: zip file might not be absolute
zip: ask.whichZipFile
nextVersion: ask.nextVersion
commit: ask.toCommit
}
return questionsRemain(_.pick(questions, properties))
## hack for @packages/server modifying cwd
process.chdir(cwd)
commitVersion = (version) ->
msg = "release #{version} [skip ci]"
repo.commitAsync(msg, {
'allow-empty': true,
})
deploy = {
meta: meta
@@ -96,19 +109,21 @@ deploy = {
## read off the argv
options = @parseOptions(process.argv)
release = (version) =>
release = ({ version, commit, nextVersion }) =>
upload.s3Manifest(version)
.then ->
if commit
commitVersion(version)
.then ->
bump.nextVersion(nextVersion)
.then ->
success("Release Complete")
.catch (err) ->
fail("Release Failed")
throw err
if v = options.version
release(v)
else
ask.whichRelease(meta.distDir(""))
.then(release)
askMissingOptions(['version', 'commit', 'nextVersion'])(options)
.then(release)
build: (options) ->
console.log('#build')