Skip to content

Commit

Permalink
Fix bump version script (#23)
Browse files Browse the repository at this point in the history
* Fix bump version script

* Fix dependencies

* Use hatch to bump the version

* Install lerna
  • Loading branch information
fcollonval authored Feb 26, 2023
1 parent 9cfcdf5 commit f0b83c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ build_dir = "jupyterlab_rise/labextension"
version-cmd = "python scripts/bump_version.py --force"

[tool.jupyter-releaser.hooks]
before-bump-version = [
"python -m pip install jupyterlab~=3.1",
"jlpm"
]
before-build-npm = [
"python -m pip install jupyterlab~=3.1",
"jlpm",
Expand Down
24 changes: 6 additions & 18 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,16 @@ def bump(force: bool, spec: str) -> None:
if len(output) > 0:
raise Exception("Must be in a clean git state with no untracked files")

curr = parse(
run(
[sys.executable, "-m", "hatch", "version", spec], cwd=HERE, encoding="utf-8", check=True
)

version = parse(
# Output maybe multi-lines if build dependencies needs to be installed.
check_output(
[sys.executable, "-m", "hatch", "version"], cwd=HERE, encoding="utf-8"
).strip("\n").split("\n")[-1]
)
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(spec)

# convert the Python version
js_version = f"{version.major}.{version.minor}.{version.micro}"
Expand All @@ -72,7 +60,7 @@ def bump(force: bool, spec: str) -> None:
lerna_cmd = f"{LERNA_CMD} {js_version}"
if force:
lerna_cmd += " --yes"
run(shlex.split(lerna_cmd), cwd=HERE)
run(shlex.split(lerna_cmd), cwd=HERE, check=True)

path = HERE.joinpath("package.json")
if path.exists():
Expand Down

0 comments on commit f0b83c2

Please sign in to comment.