From a8b96dab9b83769bb65ac9a29d63102011cfbf7d Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 12 Dec 2023 09:09:51 -0500 Subject: [PATCH] Simplify the release process: No need to pass the version to release.py (#9990) --- docs/doing-a-release.rst | 6 +++--- release.py | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/doing-a-release.rst b/docs/doing-a-release.rst index c7e82ffb4..85fe7c52a 100644 --- a/docs/doing-a-release.rst +++ b/docs/doing-a-release.rst @@ -50,10 +50,10 @@ Performing the release ---------------------- The commit that merged the version number bump is now the official release -commit for this release. You will need to have ``gpg`` installed and a ``gpg`` -key in order to do a release. Once this has happened: +commit for this release. You will need to have ``git`` configured to perform +signed tags. Once this has happened: -* Run ``python release.py release {version}``. +* Run ``python release.py release``. The release should now be available on PyPI and a tag should be available in the repository. diff --git a/release.py b/release.py index bd50130f9..4abac1a2e 100644 --- a/release.py +++ b/release.py @@ -8,6 +8,7 @@ import subprocess import click import tomllib +from packaging.version import Version def run(*args: str) -> None: @@ -22,18 +23,15 @@ def cli(): @cli.command() @click.argument("version") -def release(version: str) -> None: - """ - ``version`` should be a string like '0.4' or '1.0'. - """ +def release() -> None: base_dir = pathlib.Path(__file__).parent with (base_dir / "pyproject.toml").open("rb") as f: pyproject = tomllib.load(f) - pyproject_version = pyproject["project"]["version"] + version = pyproject["project"]["version"] - if version != pyproject_version: + if Version(version).is_prerelease: raise RuntimeError( - f"Version mismatch: pyproject.toml has {pyproject_version}" + f"Can't release, pyproject.toml version is pre-release: {version}" ) # Tag and push the tag (this will trigger the wheel builder in Actions)