Merge pull request #79 from jtpio/bump-lab
Reuse upstream scripts to update dependencies and streamline versioning
commit
6ce11f433d
@ -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,5 +1,5 @@
|
||||
{
|
||||
"extends": "./tsconfigbase",
|
||||
"include": ["packages/**/*", "builder/**/*"],
|
||||
"include": ["packages/**/*", "app/**/*", "buildutils/**/*"],
|
||||
"types": ["jest"]
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue