Add script to do a patch release

This commit is contained in:
Jeremy Tuloup 2021-01-19 09:35:54 +01:00
parent 8ebec04af0
commit 7a519059bf
8 changed files with 150 additions and 3 deletions

41
buildutils/package.json Normal file
View File

@ -0,0 +1,41 @@
{
"name": "@jupyterlab-classic/buildutils",
"version": "0.1.3",
"private": true,
"description": "JupyterLab Classic - Build Utilities",
"homepage": "https://github.com/jtpio/jupyterlab-classic",
"bugs": {
"url": "https://github.com/jtpio/jupyterlab-classic/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jtpio/jupyterlab-classic.git"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"directories": {
"lib": "lib/"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js"
],
"scripts": {
"build": "tsc",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepublishOnly": "npm run build",
"watch": "tsc -w --listEmittedFiles"
},
"dependencies": {
"@jupyterlab/buildutils": "^3.0.0",
"typescript": "~4.1.3"
},
"devDependencies": {
"@types/node": "^14.6.1",
"rimraf": "~3.0.0"
}
}

66
buildutils/src/patch.ts Normal file
View File

@ -0,0 +1,66 @@
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import commander from 'commander';
import * as utils from '@jupyterlab/buildutils';
// Specify the program signature.
commander
.description('Create a patch release')
.option('--force', 'Force the upgrade')
.action((options: any) => {
// 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();
// 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.
// Version the changed
let cmd = 'lerna version patch -m "New version" --no-push';
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');
}
// Run post-bump actions.
utils.postbump();
});
commander.parse(process.argv);

10
buildutils/tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"extends": "../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"module": "commonjs"
},
"include": ["src/*"],
"references": []
}

View File

@ -1 +1,25 @@
__version__ = "0.1.3"
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from collections import namedtuple
VersionInfo = namedtuple('VersionInfo', [
'major',
'minor',
'micro',
'releaselevel',
'serial'
])
# DO NOT EDIT THIS DIRECTLY! It is managed by bumpversion
version_info = VersionInfo(0, 1, 3, 'final', 0)
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
__version__ = '{}.{}.{}{}'.format(
version_info.major,
version_info.minor,
version_info.micro,
(''
if version_info.releaselevel == 'final'
else _specifier_[version_info.releaselevel] + str(version_info.serial)))

View File

@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"version": "0.1.3",
"version": "independent",
"useWorkspaces": true
}

View File

@ -13,6 +13,7 @@
"workspaces": {
"packages": [
"app",
"buildutils",
"packages/*"
]
},

View File

@ -1,5 +1,5 @@
{
"extends": "./tsconfigbase",
"include": ["packages/**/*", "app/**/*"],
"include": ["packages/**/*", "app/**/*", "buildutils/**/*"],
"types": ["jest"]
}

View File

@ -3182,6 +3182,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.20.tgz#f7974863edd21d1f8a494a73e8e2b3658615c340"
integrity sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==
"@types/node@^14.6.1":
version "14.14.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e"
integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A==
"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"