diff --git a/pyproject.toml b/pyproject.toml index 40fdd0d..184c467 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,9 +71,10 @@ source_dir = "src" build_dir = "jupyterlite_xeus/labextension" [tool.jupyter-releaser.options] -version_cmd = "hatch version" +version_cmd = "python ./scripts/bump_version.py" [tool.jupyter-releaser.hooks] +before-bump-version = ["python -m pip install 'jupyterlab>=4.0.0,<5'", "jlpm"] before-build-npm = [ "python -m pip install 'jupyterlab>=4.0.0,<4.3'", "jlpm", diff --git a/scripts/bump_version.py b/scripts/bump_version.py new file mode 100644 index 0000000..56e5e9f --- /dev/null +++ b/scripts/bump_version.py @@ -0,0 +1,30 @@ +import argparse +import json +from pathlib import Path +from subprocess import run + +BUMP_VERSION_CMD = "npx lerna version --no-push --force-publish --no-git-tag-version --yes" + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("version") + args = parser.parse_args() + version = args.version + + run(f"{BUMP_VERSION_CMD} {version}", shell=True, check=True) + + root = Path(__file__).parent.parent + version_file = root / "packages" / "xeus-extension" / "package.json" + package_file = root / "package.json" + + version_json = json.loads(version_file.read_text()) + version = version_json["version"].replace("-alpha.", "-a").replace("-beta.", "-b").replace("-rc.", "-rc") + + package_json = json.loads(package_file.read_text()) + package_json["version"] = version + package_file.write_text(json.dumps(package_json, indent=2)) + + +if __name__ == "__main__": + main()