From a441599cef4e832cfc841d5d75b50a25263a2fec Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 8 Jul 2022 12:24:38 -0500 Subject: [PATCH] Fix dev version handling in check release (#343) --- .github/actions/draft-release/action.yml | 2 ++ docs/source/conf.py | 2 +- jupyter_releaser/__init__.py | 2 +- jupyter_releaser/actions/draft_release.py | 2 +- jupyter_releaser/cli.py | 23 +++++++++++++++++++++-- jupyter_releaser/lib.py | 4 +++- jupyter_releaser/tests/test_cli.py | 6 +++++- jupyter_releaser/util.py | 2 +- pyproject.toml | 7 +++++-- 9 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/actions/draft-release/action.yml b/.github/actions/draft-release/action.yml index 2b1a9af7..ae022416 100644 --- a/.github/actions/draft-release/action.yml +++ b/.github/actions/draft-release/action.yml @@ -58,6 +58,8 @@ runs: export RH_SINCE=${{ inputs.since }} export RH_SINCE_LAST_STABLE=${{ inputs.since_last_stable }} export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }} + export RH_USE_CHANGELOG_VERSION=1 + export RH_VERSION_CREATE_TAG=1 # Draft Release python -m jupyter_releaser.actions.draft_release diff --git a/docs/source/conf.py b/docs/source/conf.py index edc82061..c4f5eaf9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = "Project Jupyter" # The full version, including alpha/beta/rc tags. -release = "0.22.3" +release = "0.23.0.dev0" # The short X.Y version. version = ".".join(release.split(".")[:2]) diff --git a/jupyter_releaser/__init__.py b/jupyter_releaser/__init__.py index 5fcbb029..139868eb 100644 --- a/jupyter_releaser/__init__.py +++ b/jupyter_releaser/__init__.py @@ -1,3 +1,3 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -__version__ = "0.22.3" +__version__ = "0.23.0.dev0" diff --git a/jupyter_releaser/actions/draft_release.py b/jupyter_releaser/actions/draft_release.py index 401b001e..5cfd58e6 100644 --- a/jupyter_releaser/actions/draft_release.py +++ b/jupyter_releaser/actions/draft_release.py @@ -53,7 +53,7 @@ os.chdir(curr_dir) -run_action("jupyter-releaser bump-version --use-changelog-version") +run_action("jupyter-releaser bump-version") with make_group("Handle Check Release"): if check_release: diff --git a/jupyter_releaser/cli.py b/jupyter_releaser/cli.py index bca3645a..672ee280 100644 --- a/jupyter_releaser/cli.py +++ b/jupyter_releaser/cli.py @@ -141,7 +141,16 @@ def main(force): ] version_cmd_options = [ - click.option("--version-cmd", envvar="RH_VERSION_COMMAND", help="The version command") + click.option("--version-cmd", envvar="RH_VERSION_COMMAND", help="The version command"), +] + +version_create_tag_options = [ + click.option( + "--version-create-tag", + envvar="RH_VERSION_CREATE_TAG", + is_flag=True, + help="Whether to create a tag when bumping the version", + ), ] @@ -308,11 +317,19 @@ def prep_git(ref, branch, repo, auth, username, git_url): @main.command() @add_options(version_spec_options) @add_options(version_cmd_options) +@add_options(version_create_tag_options) @add_options(changelog_path_options) @add_options(use_changelog_version_options) @add_options(python_packages_options) @use_checkout_dir() -def bump_version(version_spec, version_cmd, changelog_path, use_changelog_version, python_packages): +def bump_version( + version_spec, + version_cmd, + version_create_tag, + changelog_path, + use_changelog_version, + python_packages, +): """Prep git and env variables and bump version""" prev_dir = os.getcwd() for python_package in [p.split(":")[0] for p in python_packages]: @@ -320,6 +337,8 @@ def bump_version(version_spec, version_cmd, changelog_path, use_changelog_versio lib.bump_version( version_spec, version_cmd, changelog_path, use_changelog_version=use_changelog_version ) + if version_create_tag: + lib.create_tag() os.chdir(prev_dir) diff --git a/jupyter_releaser/lib.py b/jupyter_releaser/lib.py index 4afae8c1..c5d40ab1 100644 --- a/jupyter_releaser/lib.py +++ b/jupyter_releaser/lib.py @@ -30,7 +30,10 @@ def bump_version(version_spec, version_cmd, changelog_path, use_changelog_versio use_changelog_version=use_changelog_version, ) + +def create_tag(): version = util.get_version() + assert version is not None # A properly parsed version will have a "major" attribute parsed = parse_version(version) @@ -44,7 +47,6 @@ def bump_version(version_spec, version_cmd, changelog_path, use_changelog_versio msg = f"Tag {tag_name} already exists!" msg += " To delete run: `git push --delete origin {tag_name}`" raise ValueError(msg) - return version diff --git a/jupyter_releaser/tests/test_cli.py b/jupyter_releaser/tests/test_cli.py index 4da9c4aa..110452df 100644 --- a/jupyter_releaser/tests/test_cli.py +++ b/jupyter_releaser/tests/test_cli.py @@ -144,7 +144,10 @@ def test_bump_version_tag_exists(py_package, runner): runner(["prep-git", "--git-url", py_package]) run("git tag v1.0.1", cwd=util.CHECKOUT_NAME) with pytest.raises(ValueError): - runner(["bump-version", "--version-spec", "1.0.1"], env=dict(GITHUB_ACTIONS="")) + runner( + ["bump-version", "--version-spec", "1.0.1", "--version-create-tag"], + env=dict(GITHUB_ACTIONS=""), + ) def test_list_envvars(runner): @@ -183,6 +186,7 @@ def test_list_envvars(runner): use-changelog-version: RH_USE_CHANGELOG_VERSION username: GITHUB_ACTOR version-cmd: RH_VERSION_COMMAND +version-create-tag: RH_VERSION_CREATE_TAG version-spec: RH_VERSION_SPEC """.strip() ) diff --git a/jupyter_releaser/util.py b/jupyter_releaser/util.py index 3576b392..01ef8b44 100644 --- a/jupyter_releaser/util.py +++ b/jupyter_releaser/util.py @@ -59,7 +59,7 @@ def run(cmd, **kwargs): quiet_error = kwargs.pop("quiet_error", False) show_cwd = kwargs.pop("show_cwd", False) quiet = kwargs.pop("quiet", False) - echo = kwargs.pop("echo", False) + echo = kwargs.pop("echo", True) if echo: prefix = "COMMAND" diff --git a/pyproject.toml b/pyproject.toml index da8af6ff..4784e4b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "jupyter_releaser" -version = "0.22.3" +version = "0.23.0.dev0" description = "Jupyter Releaser for Python and/or npm packages." license = {file = "LICENSE"} authors = [{name = "Jupyter Development Team", email = "jupyter@googlegroups.com"}] @@ -58,7 +58,7 @@ test = [ jupyter-releaser = "jupyter_releaser.cli:main" [tool.tbump.version] -current = "0.22.3" +current = "0.23.0.dev0" regex = ''' (?P\d+)\.(?P\d+)\.(?P\d+) ((?Pa|b|rc|.dev)(?P\d+))? @@ -80,6 +80,9 @@ src = "docs/source/conf.py" [tool.jupyter-releaser] skip = ["check-links"] +[tool.jupyter-releaser.options] +post-version-spec = "dev" + [tool.jupyter-releaser.hooks] after-draft-release = "bash ./.github/scripts/bump_tag.sh"