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

Prepare for release #114

Merged
merged 3 commits into from
Mar 9, 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
9 changes: 5 additions & 4 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jupytercad",
"version": "0.1.0",
"version": "0.1.0-a0",
"description": "A JupyterLab extension for 3D modelling.",
"keywords": [
"jupyter",
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down Expand Up @@ -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"]
Expand Down
86 changes: 86 additions & 0 deletions scripts/bump-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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.argument("spec", nargs=1)
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")

# 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()
return

update(spec)


if __name__ == "__main__":
bump()