Skip to content

Commit

Permalink
Fix release script
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Jul 27, 2019
1 parent 97fa178 commit 8d506ad
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
3 changes: 3 additions & 0 deletions scripts/.eslintrc.js
@@ -1,5 +1,8 @@
module.exports = {
"extends": "../.eslintrc.js",
"env": {
"browser": null,
},
"parserOptions": {
"ecmaVersion": 2019,
},
Expand Down
45 changes: 30 additions & 15 deletions scripts/release.js
Expand Up @@ -22,7 +22,7 @@ const rimraf = require("rimraf")

function showHelp() {
console.error(`
scripts/release.sh increment [ --preid id ]
node scripts/release increment [ --preid id ]
Invoke as \`scripts/release.sh\` to invoke the release sequence, specifying the
version increment via \`increment\` (required). Here's how they all work:
Expand Down Expand Up @@ -62,9 +62,10 @@ const parsed = require("minimist")(process.argv.slice(2), {
string: ["preid"],
"--": true,
})
parsed._ = parsed._.concat(parsed["--"])

if (parsed.help || !parsed["--"].length) showHelp()
const publishType = parsed["--"][0]
if (parsed.help || !parsed._.length) showHelp()
const publishType = parsed._[0]
const publishPreid = parsed.preid
const publishArgs = publishType.startsWith("pre") ? ["--tag", "next"] : []
let releaseArgs = []
Expand All @@ -77,14 +78,25 @@ if (publishType.startsWith("pre") && publishType !== "prerelease") {
}

function exec(cmd, args, opts) {
return execFileSync(name, args, {
return execFileSync(cmd, args, {
windowsHide: true,
stdio: "inherit",
encoding: "utf-8",
...opts,
})
}

function getChanges() {
const result = exec("git", ["status", "-z"], {
stdio: ["inherit", "pipe", "inherit"],
})
return result.split(/\0/g).filter(Boolean)
}

if (getChanges().length) {
bail("Error: Tree must not be dirty to start!")
}

const upstream = require("./_upstream")

exec("git", ["checkout", "next"])
Expand All @@ -101,7 +113,7 @@ Flems snippets. Press enter once ready to continue.
let changelogUpdated = false
let treeDirty = false

for (const line of exec("git", ["status", "-z"]).split(/\0/g)) {
for (const line of getChanges()) {
switch (line) {
case " M CHANGELOG.md":
case "M CHANGELOG.md":
Expand Down Expand Up @@ -133,21 +145,24 @@ exec("npm", ["install-test"])

exec("npm", ["version", "-m", "v%s", publishType, ...releaseArgs])

exec("git", ["push", "--follow-tags", "origin", "master"])
exec("git", ["push", "--follow-tags", upstream.push.branch, "master"])

exec("git", ["checkout", "next"])
exec("git", ["checkout", "master", "--", "mithril.js", "mithril.min.js"])
// That's already been updated in `master`.
exec("git", ["commit", "-m", `Generated bundles for ${readVersion()} [skip ci]`])

exec("git", ["push"])
exec("git", ["push", upstream.push.branch, "next"])

exec("git", ["checkout", "master"])

exec("npm", ["login"])
exec("npm", ["publish", ...publishArgs])
exec("npm", ["logout"])
console.log("publish args: ", publishArgs)
console.log("push all: ", upstream.push.branch)
// exec("npm", ["login"])
// exec("npm", ["publish", ...publishArgs])
// exec("npm", ["logout"])
//
// // Only push after successful publish
// exec("git", ["push", "--follow-tags", "origin", "master:master", "next:next"])
// exec("git", ["push", "--follow-tags", upstream.push.branch, "master:master", "next:next"])

exec("git", ["checkout", "next"])

require("./update-docs")()
console.log("update docs")
// require("./update-docs")()

0 comments on commit 8d506ad

Please sign in to comment.