Skip to content

Commit

Permalink
Releaser: support bumping versions with next as the spec (#26)
Browse files Browse the repository at this point in the history
* Support `next` spec for incremental releases

* Fix bump version script

* Lint

* Update to v3 actions
  • Loading branch information
jtpio authored Mar 10, 2023
1 parent 8de0a8f commit 45e7dae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
version_spec: 9.9.9
version_spec: next
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: jupyterlite-pyodide-kernel-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
8 changes: 7 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ https://github.com/jupyterlite/pyodide-kernel/actions:

### Specifying a version spec

You can specify the Python version directly as the `version_spec` when using the
The `next` version spec is supported and will bump the packages as follows. For example:

- `0.1.0a0` -> `0.1.0a1`
- `0.1.0b7` -> `0.1.0b8`
- `0.1.0` -> `0.1.1`

You can also specify the Python version directly as the `version_spec` when using the
releaser workflows. For example:

- `0.1.0b8`
Expand Down
19 changes: 17 additions & 2 deletions scripts/bump-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,44 @@

import argparse
import json
from packaging.version import parse as parse_version
from pathlib import Path
from subprocess import run


ENC = dict(encoding="utf-8")
HATCH_VERSION = "hatch version"
ROOT = Path(__file__).parent.parent
PYODIDE_KERNEL_PACKAGE = ROOT / "packages" / "pyodide-kernel"
PYODIDE_PACKAGE_JSON = PYODIDE_KERNEL_PACKAGE / "package.json"
PYODIDE_KERNEL_PY_PACKAGE = PYODIDE_KERNEL_PACKAGE / "py" / "pyodide-kernel"
PIPLITE_PY_PACKAGE = PYODIDE_KERNEL_PACKAGE / "py" / "piplite"


def get_version():
cmd = run([HATCH_VERSION], capture_output=True, shell=True, check=True, cwd=ROOT)
return cmd.stdout.decode("utf-8").strip().split("\n")[-1]


def next_version():
v = parse_version(get_version())
if v.is_prerelease:
return f"{v.major}.{v.minor}.{v.micro}{v.pre[0]}{v.pre[1] + 1}"
return f"{v.major}.{v.minor}.{v.micro + 1}"


def bump():
parser = argparse.ArgumentParser()
parser.add_argument("version")
args = parser.parse_args()
py_version = args.version
py_version = next_version() if args.version == "next" else args.version
js_version = (
py_version.replace("a", "-alpha.").replace("b", "-beta.").replace("rc", "-rc.")
)

# bump the Python version with hatch for each package
for package in [ROOT, PYODIDE_KERNEL_PY_PACKAGE, PIPLITE_PY_PACKAGE]:
run(f"hatch version {py_version}", shell=True, check=True, cwd=package)
run(f"{HATCH_VERSION} {py_version}", shell=True, check=True, cwd=package)

# bump the js version
pyodide_kernel_json = json.loads(PYODIDE_PACKAGE_JSON.read_text(**ENC))
Expand Down

0 comments on commit 45e7dae

Please sign in to comment.