-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.js
32 lines (27 loc) · 903 Bytes
/
release.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { execSync } = require("child_process");
const { version } = require("./package");
const exec = command => execSync(command, { encoding: "utf8" }).trim();
const exitWithError = error => {
process.stderr.write(`\x1b[1;31m${error}\x1b[0m\n\n`);
process.exit(1);
};
const gitBranchName = exec("git rev-parse --abbrev-ref HEAD");
if (gitBranchName !== "master") {
exitWithError("please checkout the master branch to make a release!");
}
const workingCopyChanges = exec("git status --porcelain");
if (workingCopyChanges) {
exitWithError("please commit your changes before making a release!");
}
const tagExists = exec(`git tag -l "${version}"`);
if (tagExists) {
exitWithError(`${version} has already been released!`);
}
execSync(
`npm run check && git tag ${version} && git push && git push --tags && npm publish`,
{
shell: true,
stdio: "inherit",
cwd: __dirname
}
);