forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-release.ts
executable file
·73 lines (65 loc) · 2.12 KB
/
patch-release.ts
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import commander from 'commander';
import * as utils from './utils';
// Specify the program signature.
commander
.description('Create a patch release')
.option('--force', 'Force the upgrade')
.option('--all', 'Patch all JS packages instead of the changed ones')
.option('--skip-commit', 'Whether to skip commit changes')
.action((options: any) => {
utils.exitOnUuncaughtException();
// Make sure we can patch release.
const pyVersion = utils.getPythonVersion();
if (
pyVersion.includes('a') ||
pyVersion.includes('b') ||
pyVersion.includes('rc')
) {
throw new Error('Can only make a patch release from a final version');
}
// Run pre-bump actions.
utils.prebump();
// Version the changed
let cmd = `lerna version patch -m \"[ci skip] New version\" --no-push`;
if (options.all) {
cmd += ' --force-publish=*';
}
if (options.force) {
cmd += ' --yes';
}
const oldVersion = utils.run(
'git rev-parse HEAD',
{
stdio: 'pipe',
encoding: 'utf8'
},
true
);
utils.run(cmd);
const newVersion = utils.run(
'git rev-parse HEAD',
{
stdio: 'pipe',
encoding: 'utf8'
},
true
);
if (oldVersion === newVersion) {
console.debug('aborting');
// lerna didn't version anything, so we assume the user aborted
throw new Error('Lerna aborted');
}
// Patch the python version
utils.run('bumpversion patch'); // switches to alpha
utils.run('bumpversion release --allow-dirty'); // switches to beta
utils.run('bumpversion release --allow-dirty'); // switches to rc.
utils.run('bumpversion release --allow-dirty'); // switches to final.
// Run post-bump actions.
const commit = options.skipCommit !== true;
utils.postbump(commit);
});
commander.parse(process.argv);