-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathrelease.js
50 lines (46 loc) · 1.17 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
const exec = require('exec-sh');
const inquirer = require('inquirer');
const fs = require('fs');
const path = require('path');
const pkg = require('../package.json');
async function release() {
const options = await inquirer.prompt([
{
type: 'input',
name: 'version',
message: 'Version:',
default: pkg.version,
},
{
type: 'list',
name: 'beta',
message: 'Beta?',
when: (opts) => opts.version.indexOf('beta') >= 0,
choices: [
{
name: 'YES',
value: true,
},
{
name: 'NO',
value: false,
},
],
},
]);
pkg.version = options.version;
fs.writeFileSync(path.resolve(__dirname, '../package.json'), JSON.stringify(pkg, null, 2));
await exec.promise('git pull');
await exec.promise('npm i');
await exec.promise('git add .');
await exec.promise(`git commit -m ${pkg.version}`);
await exec.promise('git push');
await exec.promise(`git tag v${pkg.version}`);
await exec.promise('git push origin --tags');
if (options.beta) {
await exec.promise('npm publish --tag next');
} else {
await exec.promise('npm publish');
}
}
release();