Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for monorepo version bumps #56

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 62 additions & 62 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
{
"name": "@jupyter/root-ui-toolkit",
"version": "0.10.1",
"private": true,
"description": "UI Toolkit for Jupyter",
"keywords": [
"jupyter"
"name": "@jupyter/root-ui-toolkit",
"version": "0.10.0",
"private": true,
"description": "UI Toolkit for Jupyter",
"keywords": [
"jupyter"
],
"homepage": "https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/",
"bugs": {
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "Project Jupyter"
},
"repository": {
"type": "git",
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit.git"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build",
"build:prod": "lerna run --scope @jupyter/web-components --scope @jupyter/react-components build && lerna run --scope jupyter-ui-demo build:prod",
"clean": "lerna run clean",
"format": "yarn stylelint && prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"format:check": "yarn stylelint:check && prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"lint": "lerna run eslint",
"lint:check": "lerna run eslint:check",
"stylelint": "yarn stylelint:check --fix",
"stylelint:check": "stylelint --cache \"packages/lab-example/style/**/*.css\""
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"lerna": "^7.0.0",
"prettier": "^2.8.8",
"stylelint": "^14.9.1",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-recommended": "^8.0.0",
"stylelint-config-standard": "^26.0.0",
"stylelint-prettier": "^2.0.0"
},
"resolutions": {
"file-system-cache": "<2.4.0 || >2.4.0"
},
"packageManager": "yarn@3.6.0",
"stylelint": {
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"homepage": "https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/",
"bugs": {
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "Project Jupyter"
},
"repository": {
"type": "git",
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit.git"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build",
"build:prod": "lerna run --scope @jupyter/web-components --scope @jupyter/react-components build && lerna run --scope jupyter-ui-demo build:prod",
"clean": "lerna run clean",
"format": "yarn stylelint && prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"format:check": "yarn stylelint:check && prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"lint": "lerna run eslint",
"lint:check": "lerna run eslint:check",
"stylelint": "yarn stylelint:check --fix",
"stylelint:check": "stylelint --cache \"packages/lab-example/style/**/*.css\""
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"lerna": "^7.0.0",
"prettier": "^2.8.8",
"stylelint": "^14.9.1",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-recommended": "^8.0.0",
"stylelint-config-standard": "^26.0.0",
"stylelint-prettier": "^2.0.0"
},
"resolutions": {
"file-system-cache": "<2.4.0 || >2.4.0"
},
"packageManager": "yarn@3.6.0",
"stylelint": {
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"property-no-vendor-prefix": null,
"selector-class-pattern": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
"rules": {
"property-no-vendor-prefix": null,
"selector-class-pattern": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ source_dir = "src"
build_dir = "jupyter_ui_demo/labextension"

[tool.jupyter-releaser.options]
version_cmd = "hatch version"
version_cmd = "python scripts/bump_version.py --force"

[tool.jupyter-releaser.hooks]
before-build-npm = [
Expand Down
71 changes: 71 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import json
from pathlib import Path
from shutil import which

import click
from jupyter_releaser.util import get_version, run
from pkg_resources import parse_version # type: ignore

LERNA_CMD = "yarn run lerna version --no-push --force-publish --no-git-tag-version"


@click.command()
@click.option("--force", default=False, is_flag=True)
@click.argument("spec", nargs=1)
def bump(force, spec):
status = run("git status --porcelain").strip()
if len(status) > 0:
raise Exception("Must be in a clean git state with no untracked files")

curr = parse_version(get_version())
if spec == "next":
spec = f"{curr.major}.{curr.minor}."
if curr.pre:
p, x = curr.pre
spec += f"{curr.micro}{p}{x + 1}"
else:
spec += f"{curr.micro + 1}"

elif spec == "patch":
spec = f"{curr.major}.{curr.minor}."
if curr.pre:
spec += f"{curr.micro}"
else:
spec += f"{curr.micro + 1}"

version = parse_version(spec)

# convert the Python version
js_version = f"{version.major}.{version.minor}.{version.micro}"
if version.pre:
p, x = version.pre
p = p.replace("a", "alpha").replace("b", "beta")
js_version += f"-{p}.{x}"

# bump the JS packages
run(f"{which('yarn')} install")
lerna_cmd = f"{LERNA_CMD} {js_version}"
if force:
lerna_cmd += " --yes"
run(lerna_cmd)

HERE = Path(__file__).parent.parent.resolve()
path = HERE.joinpath("package.json")
if path.exists():
with path.open(mode="r") as f:
data = json.load(f)

data["version"] = js_version

with path.open(mode="w") as f:
json.dump(data, f, indent=2)

else:
raise FileNotFoundError(f"Could not find package.json under dir {path!s}")


if __name__ == "__main__":
bump()
Loading