forked from ryantxu/ajax-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.js
51 lines (41 loc) · 1.49 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
//
// This script makes a new git release branch and adds the 'dist' folder to it
//
const fs = require('fs');
const versionDev = require('./package.json').version;
if (!versionDev.endsWith('-dev')) {
console.warn('This script only works with a -dev version. Not: ' + versionDev);
process.exit(1);
}
// Check if the local branch has any changes not commited to git
const version = versionDev.substring(0, versionDev.lastIndexOf('-'));
const {execSync} = require('child_process');
let output = execSync('git status --untracked-files=no --porcelain').toString();
if (output.length > 0) {
console.warn('Make sure to commit all files before running this script:\n' + output);
process.exit(1);
}
console.log('Checkout and publish release branch');
execSync('git checkout -b release-' + version);
console.log('Update revision: ' + version);
execSync(
`sed -i 's/${versionDev.replace('.', '\\.')}/${version.replace(
'.',
'\\.'
)}/g' package.json`
);
// console.log('Test');
// execSync('yarn test');
console.log('Building...');
execSync('yarn build');
console.log('Save the artifacts in git');
console.log('ADD: ' + execSync('git add --verbose --force dist/').toString());
console.log('ADD: ' + execSync('git add package.json').toString());
console.log(
'COMMIT: ' + execSync(`git commit -m "adding release artifacts: ${version}"`)
);
const rev = execSync('git rev-parse HEAD')
.toString()
.trim();
console.log('Release: ', version);
console.log('TODO... tag? and propose repository info: ', rev);