Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/actions/draft-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ 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
1 change: 1 addition & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ jobs:
- name: Check Release
uses: ./.github/actions/check-release
with:
version_spec: 10.10.10
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "Project Jupyter"

# The full version, including alpha/beta/rc tags.
release = "0.23.0.dev0"
release = "0.22.3"
# The short X.Y version.
version = ".".join(release.split(".")[:2])

Expand Down
6 changes: 4 additions & 2 deletions docs/source/get_started/making_first_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ already uses Jupyter Releaser.

![Draft Changelog Workflow Dialog](../images/draft_changelog.png)

- The "New Version Spec" will usually be the full version (e.g. 0.7.1). Repos using `tbump` can also use the "next"
- The "New Version Spec" will usually be the full version (e.g. 0.7.1). Repos using `tbump` can also use the "next" or "patch"
option, which will bump the micro version (or the build version in the case of a prerelease). The "minor" option allows projects using "tbump" to bump
to the next minor version directly.
to the next minor version directly. Note: The "next" and "patch" options
are not available when using dev versions, you must use explicit versions
instead.
- Use the "since" field to select PRs prior to the latest tag to include in the release
- Type "true" in the "since the last stable git tag" if you would like to include PRs since the last non-prerelease version tagged on the target repository and branch.
- The workflow will use the GitHub API to find the relevant pull requests and make an appropriate changelog entry.
Expand Down
2 changes: 1 addition & 1 deletion jupyter_releaser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
__version__ = "0.23.0.dev0"
__version__ = "0.22.3"
2 changes: 1 addition & 1 deletion jupyter_releaser/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def extract_current(changelog_path):
def extract_current_version(changelog_path):
"""Extract the current released version from the changelog"""
body = extract_current(changelog_path)
match = re.match(r"#+ ([\da-z.]+)", body.strip())
match = re.match(r"#+ ([\d.]+)", body.strip())
if not match:
raise ValueError("Could not find previous version")
return match.groups()[0]
37 changes: 3 additions & 34 deletions jupyter_releaser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,7 @@ def main(force):
]

version_cmd_options = [
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",
),
click.option("--version-cmd", envvar="RH_VERSION_COMMAND", help="The version command")
]


Expand Down Expand Up @@ -212,15 +203,6 @@ def main(force):
),
]

use_changelog_version_options = [
click.option(
"--use-changelog-version",
envvar="RH_USE_CHANGELOG_VERSION",
is_flag=True,
help="Whether to use the changelog version if the current version is a dev version in version bump",
),
]

since_options = [
click.option(
"--since",
Expand Down Expand Up @@ -317,28 +299,15 @@ 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,
version_create_tag,
changelog_path,
use_changelog_version,
python_packages,
):
def bump_version(version_spec, version_cmd, changelog_path, 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]:
os.chdir(python_package)
lib.bump_version(
version_spec, version_cmd, changelog_path, use_changelog_version=use_changelog_version
)
if version_create_tag:
lib.create_tag()
lib.bump_version(version_spec, version_cmd, changelog_path)
os.chdir(prev_dir)


Expand Down
18 changes: 4 additions & 14 deletions jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,11 @@
from jupyter_releaser import changelog, npm, python, util


def bump_version(version_spec, version_cmd, changelog_path, use_changelog_version):
def bump_version(version_spec, version_cmd, changelog_path):
"""Bump the version and verify new version"""
util.bump_version(
version_spec,
version_cmd=version_cmd,
changelog_path=changelog_path,
use_changelog_version=use_changelog_version,
)

util.bump_version(version_spec, version_cmd=version_cmd, changelog_path=changelog_path)

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)
Expand All @@ -47,6 +39,7 @@ def create_tag():
msg = f"Tag {tag_name} already exists!"
msg += " To delete run: `git push --delete origin {tag_name}`"
raise ValueError(msg)

return version


Expand Down Expand Up @@ -257,10 +250,7 @@ def draft_release(
# Bump to post version if given
if post_version_spec:
post_version = bump_version(
post_version_spec,
version_cmd=version_cmd,
changelog_path=changelog_path,
use_changelog_version=False,
post_version_spec, version_cmd=version_cmd, changelog_path=changelog_path
)
util.log(post_version_message.format(post_version=post_version))
util.run(f'git commit -a -m "Bump to {post_version}"')
Expand Down
14 changes: 1 addition & 13 deletions jupyter_releaser/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ def test_bump_version(npm_package, runner):
assert version == "1.0.1-rc0"


def test_bump_version_use_changelog(npm_package, runner):
runner(["prep-git", "--git-url", npm_package])
runner(["bump-version", "--use-changelog-version"])
version = util.get_version()
assert version == "1.0.0"


def test_bump_version_bad_version(py_package, runner):
runner(["prep-git", "--git-url", py_package])
with pytest.raises(CalledProcessError):
Expand All @@ -144,10 +137,7 @@ 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", "--version-create-tag"],
env=dict(GITHUB_ACTIONS=""),
)
runner(["bump-version", "--version-spec", "1.0.1"], env=dict(GITHUB_ACTIONS=""))


def test_list_envvars(runner):
Expand Down Expand Up @@ -183,10 +173,8 @@ def test_list_envvars(runner):
tag-message: RH_TAG_MESSAGE
twine-cmd: TWINE_COMMAND
twine-registry: TWINE_REGISTRY
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()
)
Expand Down
25 changes: 6 additions & 19 deletions jupyter_releaser/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
from pathlib import Path

import pytest
import toml
from ghapi.core import GhApi

Expand Down Expand Up @@ -294,30 +295,16 @@ def test_bump_version_reg(py_package):


def test_bump_version_dev(py_package):
changelog_path = py_package / "CHANGELOG.md"
util.bump_version("dev")
assert util.get_version() == "0.1.0.dev0"
util.bump_version("dev")
assert util.get_version() == "0.1.0.dev1"
# Should get the version from the changelog
util.bump_version("next", changelog_path=changelog_path)
assert util.get_version() == "0.0.2"
util.bump_version("dev")
assert util.get_version() == "0.1.0.dev0"
util.bump_version("patch", changelog_path=changelog_path, use_changelog_version=True)
assert util.get_version() == "0.0.1"
util.bump_version("1.0.0.dev0")
text = changelog_path.read_text(encoding="utf-8")
text = text.replace("0.0.1", "0.0.1a1")
changelog_path.write_text(text, encoding="utf-8")
util.bump_version("patch", changelog_path=changelog_path)
assert util.get_version() == "0.0.1a2"
util.bump_version("1.0.0.dev0")
util.bump_version("patch", changelog_path=changelog_path, use_changelog_version=True)
assert util.get_version() == "0.0.1a1"
util.bump_version("1.0.0.dev0")
with pytest.raises(ValueError):
util.bump_version("next")
with pytest.raises(ValueError):
util.bump_version("patch")
util.bump_version("minor")
assert util.get_version() == "1.0.0"
assert util.get_version() == "0.1.0"


def test_get_config_python(py_package):
Expand Down
20 changes: 5 additions & 15 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", True)
echo = kwargs.pop("echo", False)

if echo:
prefix = "COMMAND"
Expand Down Expand Up @@ -231,7 +231,7 @@ def create_release_commit(version, release_message=None, dist_dir="dist"):
return shas


def bump_version(version_spec, *, changelog_path="", version_cmd="", use_changelog_version=False):
def bump_version(version_spec, *, changelog_path="", version_cmd=""):
"""Bump the version"""
# Look for config files to determine version command if not given
if not version_cmd:
Expand Down Expand Up @@ -271,19 +271,9 @@ def bump_version(version_spec, *, changelog_path="", version_cmd="", use_changel
if v.is_devrelease:
# bump from the version in the changelog.
if version_spec in ["patch", "next"]:
from jupyter_releaser.changelog import extract_current_version

v = parse_version(extract_current_version(changelog_path))
assert isinstance(v, Version)
if use_changelog_version:
version_spec = v
elif v.is_prerelease:
assert v.pre
# Bump to the next prerelease.
version_spec = f"{v.major}.{v.minor}.{v.micro}{v.pre[0]}{v.pre[1] + 1}"
else:
# Bump to the next micro.
version_spec = f"{v.major}.{v.minor}.{v.micro + 1}"
raise ValueError(
"We do not support 'patch' or 'next' when dev versions are used, please use an explicit version."
)

# Drop the dev portion and move to the minor release.
elif version_spec == "minor":
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "jupyter_releaser"
version = "0.23.0.dev0"
version = "0.22.3"
description = "Jupyter Releaser for Python and/or npm packages."
license = {file = "LICENSE"}
authors = [{name = "Jupyter Development Team", email = "[email protected]"}]
Expand Down Expand Up @@ -58,7 +58,7 @@ test = [
jupyter-releaser = "jupyter_releaser.cli:main"

[tool.tbump.version]
current = "0.23.0.dev0"
current = "0.22.3"
regex = '''
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
Expand All @@ -80,9 +80,6 @@ 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"

Expand Down