-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
executable file
·49 lines (36 loc) · 1.58 KB
/
publish.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const packageJson = require('./package.json');
const version = packageJson.version;
const description = packageJson.versionDescription;
// function to run bash commands
const execSync = require('child_process').execSync;
function runShell(command) {
return execSync(command, { encoding: 'utf-8' });
}
console.log(`releasing busy (${version} - ${description})...`);
const lastCommitMessage = runShell('git log -1 --pretty=%B');
if (lastCommitMessage.includes(version) || lastCommitMessage.includes(description)) {
console.error(`**ABORTING: "version ${version} - ${description}" has already been published!**`);
console.error(`**if applicable, in package.json, update "version" and "versionDescription" and try again.**`);
process.exit(0);
}
console.info(` installing npm dependencies...`);
runShell('npm install');
console.info(` building browser dist folder...`);
const buildOutput = runShell('npm run build-production');
if (buildOutput.includes('error')) {
console.error(`**ABORTING: "npm run build-production returned error`, buildOutput);
process.exit(0);
}
console.info(` git staging any modified/deleted/new files...`);
runShell(`git add --all`);
console.info(` git committing...`);
runShell(`git commit -m "Release version ${version} - ${description}"`);
console.info(` git tagging...`);
runShell(`git tag ${version}`);
runShell(`git tag -f latest`);
console.info(` git pushing...`);
runShell(`git push origin master :refs/tags/latest`);
runShell(`git push origin master --tags`);
console.info(` publishing to npm...`);
runShell(`npm publish`);
process.exit(0);