-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.js
52 lines (48 loc) · 1.48 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import execThen from './utils/execThen';
import packingCrx from './utils/packingCrx';
const releaseType = process.argv.slice(2)[0];
const manifest = require('./src/manifest.json');
const { version } = manifest;
let [major, minor, patch ] = version.split('.');
let newMajor = major,
newMinor = minor,
newPatch = minor;
switch(releaseType) {
case 'patch': {
newPatch = parseInt(patch, 10) + 1;
}
break;
case 'minor': {
newMinor = parseInt(minor, 10) + 1;
newPatch = 0;
}
break;
case 'major': {
newMajor = parseInt(major) + 1;
newMinor = 0;
newPatch = 0;
}
break;
default:
console.log('No valid arg passed! It has to be one of patch, minor or major');
process.exit(0);
}
const newVersion = `${newMajor}.${newMinor}.${newPatch}`;
console.log(`${version} -> ${newVersion}`);
packingCrx(`${newVersion}`)
.then(() =>
execThen('git rev-parse --abbrev-ref HEAD')
.then(({ stdout: branch }) => branch.replace(/(\r\n|\n|\r)/gm, ""))
.then((branch) => {
return execThen('git add .')
.then(() => execThen(`git commit -m"Release: ${newVersion}."`))
.then(() =>
// specific steps for prs
execThen(`git push origin ${branch}`)
.then(() => execThen('git checkout master'))
.then(() => execThen(`git merge --no-ff ${branch}`))
)
.then(() => execThen(`git tag v${newVersion}`))
.then(() => execThen('git push origin master --tags'))
})
);