-
Notifications
You must be signed in to change notification settings - Fork 276
/
bump-version.py
52 lines (40 loc) 路 1.76 KB
/
bump-version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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/voila-dashboards/voila/blob/master/scripts/bump-version.py
import json
from pathlib import Path
import click
from jupyter_releaser.util import bump_version as bump_py
from jupyter_releaser.util import run
ENC = dict(encoding="utf-8")
ROOT = Path(__file__).parent.parent
ROOT_PACKAGE_JSON = ROOT / "package.json"
APP_PACKAGE_JSON = ROOT / "app" / "package.json"
APP_JUPYTERLITE_JSON = ROOT / "app" / "jupyter-lite.json"
@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")
# bump Python version
bump_py(spec, changelog_path="CHANGELOG.md")
# read the new app version
app_json = json.loads(ROOT_PACKAGE_JSON.read_text(**ENC))
py_version = app_json["version"]
js_version = py_version.replace("a", "-alpha.").replace("b", "-beta.").replace("rc", "-rc.")
# save the new version to the app jupyter-lite.json
jupyterlite_json = json.loads(APP_JUPYTERLITE_JSON.read_text(**ENC))
jupyterlite_json["jupyter-config-data"]["appVersion"] = js_version
APP_JUPYTERLITE_JSON.write_text(json.dumps(jupyterlite_json), **ENC)
run(f"jlpm prettier --write {APP_JUPYTERLITE_JSON}")
# bump the JS packages
cmd = f"jlpm run lerna version --force-publish --no-push --no-git-tag-version {js_version}"
if force:
cmd += " --yes"
run(cmd)
if __name__ == "__main__":
bump()