-
Notifications
You must be signed in to change notification settings - Fork 505
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
Add a script to bump the version #954
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3f8953c
Add a script to bump the version
jtpio 78c10ac
Ignore scripts
jtpio e416ef8
Add bumpversion config
jtpio 830b290
quiet
jtpio b8103d2
Add jupyter releaser config
jtpio 33ba290
Handle version spec
jtpio 1a326bd
Add update logic to bump version script
jtpio 69aaacc
Patch npm packages
jtpio d342578
Sync the voila frontend version
jtpio 246e38d
Force flag
jtpio 09e9acb
Fix releaser hook
jtpio 74f836e
Install jupyterlab before bumping
jtpio 4ce1f64
Flake8
jtpio 9bb36c0
More flake8
jtpio 4ac2ff4
Fix formatting
jtpio 9a199cf
Update hook
jtpio 81fed59
Update RELEASE.md
jtpio 168e165
Add note about bumping versions
jtpio a67f579
Build prod
jtpio eeac2d5
Check git status before bumping
jtpio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[bumpversion] | ||
current_version = 0, 2, 11, "final", 0 | ||
commit = False | ||
tag = False | ||
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+) | ||
serialize = | ||
{major}, {minor}, {patch}, "{release}", {build} | ||
|
||
[bumpversion:part:release] | ||
optional_value = final | ||
values = | ||
alpha | ||
beta | ||
candidate | ||
final | ||
|
||
[bumpversion:part:build] | ||
|
||
[bumpversion:file:voila/_version.py] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# 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 run | ||
|
||
|
||
OPTIONS = ["major", "minor", "release", "build"] | ||
|
||
|
||
def get_python_version(): | ||
"""Return the version of the voila Python package""" | ||
import voila | ||
|
||
return voila.__version__ | ||
|
||
|
||
def patch(force=False): | ||
python_version = get_python_version() | ||
if "a" in python_version or "b" in python_version or "rc" in python_version: | ||
raise Exception("Can only make a patch release from a final version") | ||
|
||
run("bumpversion patch", quiet=True) | ||
# switches to alpha | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to beta | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to rc. | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to final. | ||
|
||
# Version the changed | ||
cmd = "jlpm run lerna version patch --no-push --force-publish --no-git-tag-version" | ||
if force: | ||
cmd += " --yes" | ||
run(cmd) | ||
|
||
|
||
def update(spec, force=False): | ||
prev = get_python_version() | ||
|
||
# Make sure we have a valid version spec. | ||
if spec not in OPTIONS: | ||
raise Exception(f"Version spec must be one of: {OPTIONS}") | ||
|
||
is_final = "a" not in prev and "b" not in prev and "c" not in prev | ||
|
||
if is_final and spec == "release": | ||
raise Exception('Use "major" or "minor" to switch back to alpha release') | ||
|
||
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"bumpversion {spec}") | ||
return | ||
|
||
# Determine the version spec to use for lerna. | ||
lerna_version = "preminor" | ||
if spec == "build": | ||
lerna_version = "prerelease" | ||
# a -> b | ||
elif spec == "release" and "a" in prev: | ||
lerna_version = "prerelease --preid=beta" | ||
# b -> rc | ||
elif spec == "release" and "b" in prev: | ||
lerna_version = "prerelease --preid=rc" | ||
# rc -> final | ||
elif spec == "release" and "c" in prev: | ||
lerna_version = "patch" | ||
if lerna_version == "preminor": | ||
lerna_version += " --preid=alpha" | ||
|
||
cmd = f"jlpm run lerna version --force-publish --no-push --no-git-tag-version {lerna_version}" | ||
if force: | ||
cmd += " --yes" | ||
|
||
# For a preminor release, we bump 10 minor versions so that we do | ||
# not conflict with versions during minor releases of the top level package. | ||
if lerna_version == "preminor": | ||
for i in range(10): | ||
run(cmd) | ||
else: | ||
run(cmd) | ||
|
||
# Bump the version. | ||
run(f"bumpversion {spec} --allow-dirty") | ||
|
||
|
||
@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") | ||
|
||
if spec == "patch": | ||
patch(force) | ||
return | ||
|
||
update(spec, force) | ||
|
||
|
||
if __name__ == "__main__": | ||
bump() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now this package is still private, but will probably be released too when #846 lands