Skip to content

Commit 7a51905

Browse files
committed
Add script to do a patch release
1 parent 8ebec04 commit 7a51905

File tree

8 files changed

+150
-3
lines changed

8 files changed

+150
-3
lines changed

buildutils/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@jupyterlab-classic/buildutils",
3+
"version": "0.1.3",
4+
"private": true,
5+
"description": "JupyterLab Classic - Build Utilities",
6+
"homepage": "https://github.com/jtpio/jupyterlab-classic",
7+
"bugs": {
8+
"url": "https://github.com/jtpio/jupyterlab-classic/issues"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/jtpio/jupyterlab-classic.git"
13+
},
14+
"license": "BSD-3-Clause",
15+
"author": "Project Jupyter",
16+
"main": "lib/index.js",
17+
"types": "lib/index.d.ts",
18+
"directories": {
19+
"lib": "lib/"
20+
},
21+
"files": [
22+
"lib/*.d.ts",
23+
"lib/*.js.map",
24+
"lib/*.js"
25+
],
26+
"scripts": {
27+
"build": "tsc",
28+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
29+
"prepublishOnly": "npm run build",
30+
"watch": "tsc -w --listEmittedFiles"
31+
},
32+
"dependencies": {
33+
"@jupyterlab/buildutils": "^3.0.0",
34+
"typescript": "~4.1.3"
35+
},
36+
"devDependencies": {
37+
"@types/node": "^14.6.1",
38+
"rimraf": "~3.0.0"
39+
}
40+
}
41+

buildutils/src/patch.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* -----------------------------------------------------------------------------
2+
| Copyright (c) Jupyter Development Team.
3+
| Distributed under the terms of the Modified BSD License.
4+
|----------------------------------------------------------------------------*/
5+
6+
import commander from 'commander';
7+
8+
import * as utils from '@jupyterlab/buildutils';
9+
10+
// Specify the program signature.
11+
commander
12+
.description('Create a patch release')
13+
.option('--force', 'Force the upgrade')
14+
.action((options: any) => {
15+
// Make sure we can patch release.
16+
const pyVersion = utils.getPythonVersion();
17+
if (
18+
pyVersion.includes('a') ||
19+
pyVersion.includes('b') ||
20+
pyVersion.includes('rc')
21+
) {
22+
throw new Error('Can only make a patch release from a final version');
23+
}
24+
25+
// Run pre-bump actions.
26+
utils.prebump();
27+
28+
// Patch the python version
29+
utils.run('bumpversion patch'); // switches to alpha
30+
utils.run('bumpversion release --allow-dirty'); // switches to beta
31+
utils.run('bumpversion release --allow-dirty'); // switches to rc.
32+
utils.run('bumpversion release --allow-dirty'); // switches to final.
33+
34+
// Version the changed
35+
let cmd = 'lerna version patch -m "New version" --no-push';
36+
if (options.force) {
37+
cmd += ' --yes';
38+
}
39+
const oldVersion = utils.run(
40+
'git rev-parse HEAD',
41+
{
42+
stdio: 'pipe',
43+
encoding: 'utf8'
44+
},
45+
true
46+
);
47+
utils.run(cmd);
48+
const newVersion = utils.run(
49+
'git rev-parse HEAD',
50+
{
51+
stdio: 'pipe',
52+
encoding: 'utf8'
53+
},
54+
true
55+
);
56+
if (oldVersion === newVersion) {
57+
console.debug('aborting');
58+
// lerna didn't version anything, so we assume the user aborted
59+
throw new Error('Lerna aborted');
60+
}
61+
62+
// Run post-bump actions.
63+
utils.postbump();
64+
});
65+
66+
commander.parse(process.argv);

buildutils/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfigbase",
3+
"compilerOptions": {
4+
"outDir": "lib",
5+
"rootDir": "src",
6+
"module": "commonjs"
7+
},
8+
"include": ["src/*"],
9+
"references": []
10+
}

jupyterlab_classic/_version.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
__version__ = "0.1.3"
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
from collections import namedtuple
5+
6+
VersionInfo = namedtuple('VersionInfo', [
7+
'major',
8+
'minor',
9+
'micro',
10+
'releaselevel',
11+
'serial'
12+
])
13+
14+
# DO NOT EDIT THIS DIRECTLY! It is managed by bumpversion
15+
version_info = VersionInfo(0, 1, 3, 'final', 0)
16+
17+
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
18+
19+
__version__ = '{}.{}.{}{}'.format(
20+
version_info.major,
21+
version_info.minor,
22+
version_info.micro,
23+
(''
24+
if version_info.releaselevel == 'final'
25+
else _specifier_[version_info.releaselevel] + str(version_info.serial)))

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"npmClient": "yarn",
3-
"version": "0.1.3",
3+
"version": "independent",
44
"useWorkspaces": true
55
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"workspaces": {
1414
"packages": [
1515
"app",
16+
"buildutils",
1617
"packages/*"
1718
]
1819
},

tsconfig.eslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "./tsconfigbase",
3-
"include": ["packages/**/*", "app/**/*"],
3+
"include": ["packages/**/*", "app/**/*", "buildutils/**/*"],
44
"types": ["jest"]
55
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,11 @@
31823182
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.20.tgz#f7974863edd21d1f8a494a73e8e2b3658615c340"
31833183
integrity sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==
31843184

3185+
"@types/node@^14.6.1":
3186+
version "14.14.21"
3187+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e"
3188+
integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A==
3189+
31853190
"@types/normalize-package-data@^2.4.0":
31863191
version "2.4.0"
31873192
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"

0 commit comments

Comments
 (0)