From 7a519059bfa7a3df61fc6282ccd08c7dc6054ba1 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup <jeremy.tuloup@gmail.com> Date: Tue, 19 Jan 2021 09:35:54 +0100 Subject: [PATCH] Add script to do a patch release --- buildutils/package.json | 41 +++++++++++++++++++++ buildutils/src/patch.ts | 66 ++++++++++++++++++++++++++++++++++ buildutils/tsconfig.json | 10 ++++++ jupyterlab_classic/_version.py | 26 +++++++++++++- lerna.json | 2 +- package.json | 1 + tsconfig.eslint.json | 2 +- yarn.lock | 5 +++ 8 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 buildutils/package.json create mode 100644 buildutils/src/patch.ts create mode 100644 buildutils/tsconfig.json diff --git a/buildutils/package.json b/buildutils/package.json new file mode 100644 index 000000000..821d64b7e --- /dev/null +++ b/buildutils/package.json @@ -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" + } +} + diff --git a/buildutils/src/patch.ts b/buildutils/src/patch.ts new file mode 100644 index 000000000..35ea1f7ac --- /dev/null +++ b/buildutils/src/patch.ts @@ -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); diff --git a/buildutils/tsconfig.json b/buildutils/tsconfig.json new file mode 100644 index 000000000..945e3ce9d --- /dev/null +++ b/buildutils/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfigbase", + "compilerOptions": { + "outDir": "lib", + "rootDir": "src", + "module": "commonjs" + }, + "include": ["src/*"], + "references": [] +} diff --git a/jupyterlab_classic/_version.py b/jupyterlab_classic/_version.py index acf3be3eb..a53900b5e 100644 --- a/jupyterlab_classic/_version.py +++ b/jupyterlab_classic/_version.py @@ -1 +1,25 @@ -__version__ = "0.1.3" \ No newline at end of file +# 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))) diff --git a/lerna.json b/lerna.json index 340c0f687..5349e45d5 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "npmClient": "yarn", - "version": "0.1.3", + "version": "independent", "useWorkspaces": true } diff --git a/package.json b/package.json index 30a5c2ce4..78dc49260 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "workspaces": { "packages": [ "app", + "buildutils", "packages/*" ] }, diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index f9cdb9bb1..29080d827 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,5 +1,5 @@ { "extends": "./tsconfigbase", - "include": ["packages/**/*", "app/**/*"], + "include": ["packages/**/*", "app/**/*", "buildutils/**/*"], "types": ["jest"] } diff --git a/yarn.lock b/yarn.lock index 4185f352a..9e7f551ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"