Simplify the release process: No need to pass the version to release.py (#9990)

This commit is contained in:
Alex Gaynor 2023-12-12 09:09:51 -05:00 committed by GitHub
parent d81fd662f7
commit a8b96dab9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

@ -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.

View file

@ -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)