From b94a25542f5a4cf03d1bfe82cc245c9fb85b42f8 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 8 Mar 2023 17:36:43 +0100 Subject: [PATCH 1/3] Prepare for release --- package.json | 2 +- pyproject.toml | 4 +- scripts/bump-version.py | 87 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 scripts/bump-version.py diff --git a/package.json b/package.json index f30f63d5..0aeae077 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jupytercad", - "version": "0.1.0", + "version": "0.1.0-a0", "description": "A JupyterLab extension for 3D modelling.", "keywords": [ "jupyter", diff --git a/pyproject.toml b/pyproject.toml index 78e9a571..906deed0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ readme = "README.md" license = { file = "LICENSE" } requires-python = ">=3.7" dependencies = [ - "jupyterlab==4.0.0a32", + "jupyterlab>=4.0.0a32", "jupyter_server>=2.0.6", "jupyter_ydoc>=0.2.0,<0.3.0" ] @@ -66,7 +66,7 @@ source_dir = "src" build_dir = "jupytercad/labextension" [tool.jupyter-releaser.options] -version_cmd = "hatch version" +version-cmd = "python scripts/bump-version.py" [tool.jupyter-releaser.hooks] before-build-npm = ["python -m pip install jupyterlab>=4.0.0a32", "jlpm", "jlpm build:prod"] diff --git a/scripts/bump-version.py b/scripts/bump-version.py new file mode 100644 index 00000000..aed89e5f --- /dev/null +++ b/scripts/bump-version.py @@ -0,0 +1,87 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License.import click + +# Heavily inspired by: +# - https://github.com/jupyterlab/jupyterlab/blob/master/buildutils/src/bumpversion.ts +# - https://github.com/jupyterlab/retrolab/blob/main/buildutils/src/release-bump.ts + +import click +from jupyter_releaser.util import is_prerelease, get_version, run + + +OPTIONS = ["major", "minor", "release", "build", "patch", "next"] + + +def patch(): + version = get_version() + if is_prerelease(version): + raise Exception("Can only make a patch release from a final version") + + run("hatch version patch", quiet=True) + + +def update(spec): + prev = get_version() + + is_final = not is_prerelease(prev) + + if is_final and spec == "build": + raise Exception("Cannot increment a build on a final release") + + # If this is a major release during the alpha cycle, bump + # just the Python version. + if "a" in prev and spec == "major": + run(f"hatch version {spec}") + return + + # Determine the version spec to use for hatch + py_spec = spec + if spec == "build": + if 'a' in prev: + py_spec = 'a' + elif 'b' in prev: + py_spec = 'b' + elif 'rc' in prev: + py_spec = 'rc' + # a -> b + elif spec == "release" and "a" in prev: + py_spec = 'beta' + # b -> rc + elif spec == "release" and "b" in prev: + py_spec = 'rc' + # rc -> final + elif spec == "release" and "c" in prev: + py_spec = 'release' + elif spec == "release": + py_spec = 'minor,alpha' + + # Bump the Python version + run(f"hatch version {py_spec}") + + +@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") + + # Make sure we have a valid version spec. + if spec not in OPTIONS: + raise ValueError(f"Version spec must be one of: {OPTIONS}") + + prev = get_version() + is_final = not is_prerelease(prev) + if spec == "next": + spec = "patch" if is_final else "build" + + if spec == "patch": + patch(force) + return + + update(spec, force) + + +if __name__ == "__main__": + bump() From a2e38ef8fd4b304e3df6082d27a8edf7a1a84935 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 9 Mar 2023 10:41:33 +0100 Subject: [PATCH 2/3] Remove force option --- scripts/bump-version.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/bump-version.py b/scripts/bump-version.py index aed89e5f..22180f7c 100644 --- a/scripts/bump-version.py +++ b/scripts/bump-version.py @@ -60,9 +60,8 @@ def update(spec): @click.command() -@click.option("--force", default=False, is_flag=True) @click.argument("spec", nargs=1) -def bump(force, spec): +def bump(spec): status = run("git status --porcelain").strip() if len(status) > 0: raise Exception("Must be in a clean git state with no untracked files") @@ -77,10 +76,10 @@ def bump(force, spec): spec = "patch" if is_final else "build" if spec == "patch": - patch(force) + patch() return - update(spec, force) + update(spec) if __name__ == "__main__": From daf6a87f652bbc344529b267fbd9c500f1c708c5 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 9 Mar 2023 10:55:37 +0100 Subject: [PATCH 3/3] Run check-release on next --- .github/workflows/check-release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 5684d0a7..c1a13ac4 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -21,20 +21,21 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + - name: Base Setup uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - + - name: Install Dependencies run: | pip install -e . - + - name: Check Release if: ${{ matrix.group == 'check_release' }} uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - + version_spec: next + - name: Upload Distributions if: ${{ matrix.group == 'check_release' }} uses: actions/upload-artifact@v3