Merge pull request #79 from jtpio/bump-lab

Reuse upstream scripts to update dependencies and streamline versioning
Jeremy Tuloup 5 years ago committed by GitHub
commit 6ce11f433d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,20 @@
[bumpversion]
current_version = 0, 1, 3, 'final', 0
commit = False
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \'(?P<release>\S+)\'\,\ (?P<build>\d+)
serialize =
{major}, {minor}, {patch}, '{release}', {build}
[bumpversion:part:release]
optional_value = final
values =
alpha
beta
candidate
final
[bumpversion:part:build]
[bumpversion:file:jupyterlab_classic/_version.py]

@ -0,0 +1,61 @@
name: Build Utilities
on:
push:
branches: [ main ]
pull_request:
branches: '*'
defaults:
run:
shell: bash -l {0}
jobs:
scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip
jlpm
jlpm run build
- name: Configure git identity to commit
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Reset version
run: |
# TODO: improve this with a mock package?
# This step is to ensure the workflow always starts with a final version
sed -i -E "s/VersionInfo\(.*\)/VersionInfo\(9, 8, 7, 'final', 0\)/" jupyterlab_classic/_version.py
sed -i -E "s/current_version = .*/current_version = 9, 8, 7, 'final', 0/" .bumpversion.cfg
jlpm run lerna version 9.8.7 --no-push --force-publish --no-git-tag-version --yes
git commit -am "Release 9.8.7"
- name: Patch Release
run: |
jlpm release:patch --force
- name: Minor Release
run: |
jlpm release:bump minor --force
- name: Release Cycle
run: |
# beta
jlpm release:bump release --force
# rc
jlpm release:bump release --force
# final
jlpm release:bump release --force
- name: Major Release
run: |
jlpm release:bump major --force

@ -1,5 +1,5 @@
{
"name": "@jupyterlab-classic/builder",
"name": "@jupyterlab-classic/app",
"version": "0.1.3",
"private": true,
"scripts": {

@ -0,0 +1,42 @@
{
"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",
"commander": "^6.2.0",
"typescript": "~4.1.3"
},
"devDependencies": {
"@types/node": "^14.6.1",
"rimraf": "~3.0.0"
}
}

@ -0,0 +1,109 @@
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
/**
* Inspired by: https://github.com/jupyterlab/jupyterlab/blob/master/buildutils/src/bumpversion.ts
*/
import * as utils from '@jupyterlab/buildutils';
import commander from 'commander';
import { postbump } from './utils';
// Specify the program signature.
commander
.description('Update the version')
.option('--dry-run', 'Dry run')
.option('--force', 'Force the upgrade')
.arguments('<spec>')
.action((spec: any, opts: any) => {
// Get the previous version.
const prev = utils.getPythonVersion();
// Make sure we have a valid version spec.
const options = ['major', 'minor', 'release', 'build'];
if (options.indexOf(spec) === -1) {
throw new Error(`Version spec must be one of: ${options}`);
}
if (
prev.indexOf('a') === -1 &&
prev.indexOf('b') === -1 &&
prev.indexOf('rc') === -1 &&
spec === 'release'
) {
throw new Error('Use "major" or "minor" to switch back to alpha release');
}
if (
prev.indexOf('a') === -1 &&
prev.indexOf('b') === -1 &&
prev.indexOf('rc') === -1 &&
spec === 'build'
) {
throw new Error('Cannot increment a build on a final release');
}
// Run pre-bump script.
utils.prebump();
// Handle dry runs.
if (opts.dryRun) {
utils.run(`bumpversion --dry-run --verbose ${spec}`);
return;
}
// If this is a major release during the alpha cycle, bump
// just the Python version.
if (prev.indexOf('a') !== -1 && spec === 'major') {
// Bump the version.
utils.run(`bumpversion ${spec}`);
// Run the post-bump script.
postbump();
return;
}
// Determine the version spec to use for lerna.
let lernaVersion = 'preminor';
if (spec === 'build') {
lernaVersion = 'prerelease';
// a -> b
} else if (spec === 'release' && prev.indexOf('a') !== -1) {
lernaVersion = 'prerelease --preid=beta';
// b -> rc
} else if (spec === 'release' && prev.indexOf('b') !== -1) {
lernaVersion = 'prerelease --preid=rc';
// rc -> final
} else if (spec === 'release' && prev.indexOf('rc') !== -1) {
lernaVersion = 'patch';
}
if (lernaVersion === 'preminor') {
lernaVersion += ' --preid=alpha';
}
let cmd = `jlpm run lerna version --force-publish --no-push --no-git-tag-version ${lernaVersion}`;
if (opts.force) {
cmd += ' --yes';
}
// For a preminor release, we bump 10 minor versions so that we do
// not conflict with versions during minor releases of the top
// level package.
if (lernaVersion === 'preminor') {
for (let i = 0; i < 10; i++) {
utils.run(cmd);
}
} else {
utils.run(cmd);
}
// Bump the version.
utils.run(`bumpversion ${spec} --allow-dirty`);
// Run the post-bump script.
postbump();
});
commander.parse(process.argv);

@ -0,0 +1,52 @@
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
/**
* Inspired by: https://github.com/jupyterlab/jupyterlab/blob/master/buildutils/src/patch-release.ts
*/
import * as utils from '@jupyterlab/buildutils';
import commander from 'commander';
import { postbump } from './utils';
// 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 =
'jlpm run lerna version patch --no-push --force-publish --no-git-tag-version';
if (options.force) {
cmd += ' --yes';
}
utils.run(cmd);
// Run post-bump actions.
postbump();
});
commander.parse(process.argv);

@ -0,0 +1,8 @@
import { getPythonVersion, run } from '@jupyterlab/buildutils';
export function postbump(): void {
const newPyVersion = getPythonVersion();
// Commit changes.
run(`git commit -am "Release ${newPyVersion}"`);
run(`git tag ${newPyVersion}`);
}

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

@ -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)))

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

@ -1,18 +1,19 @@
{
"private": true,
"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"
},
"bugs": {
"url": "https://github.com/jtpio/jupyterlab-classic/issues"
},
"license": "BSD-3-Clause",
"author": "JupyterLab Classic Contributors",
"workspaces": {
"packages": [
"builder",
"app",
"buildutils",
"packages/*"
]
},
@ -21,20 +22,29 @@
"build:prod": "lerna run build:prod",
"build:test": "lerna run build:test",
"clean": "lerna run clean",
"install": "lerna bootstrap",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install": "lerna bootstrap",
"prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"publish": "yarn run clean && yarn run build && lerna publish",
"test": "lerna run test"
"release:bump": "node ./buildutils/lib/release-bump.js",
"release:patch": "node ./buildutils/lib/release-patch.js",
"test": "lerna run test",
"update:dependency": "node ./node_modules/@jupyterlab/buildutils/lib/update-dependency.js --lerna"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"@jupyterlab/buildutils": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^7.10.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"husky": "^3",
@ -49,10 +59,5 @@
"rimraf": "^3.0.2",
"shell-quote": "^1.7.2",
"typescript": "~4.1.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
}

@ -23,7 +23,7 @@ PACKAGE_NAME = NAME.replace("-", "_")
version = get_version(os.path.join(PACKAGE_NAME, "_version.py"))
main_bundle_dest = os.path.join(HERE, PACKAGE_NAME, "static")
main_bundle_source = os.path.join(HERE, "builder")
main_bundle_source = os.path.join(HERE, "app")
labext_name = "@jupyterlab-classic/lab-extension"
lab_extension_dest = os.path.join(HERE, PACKAGE_NAME, "labextension")

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

@ -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"

Loading…
Cancel
Save