Skip to content

Commit

Permalink
fix release_check
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Aug 25, 2024
1 parent 42c957d commit 3821654
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 7 additions & 12 deletions .ci/release_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Ensure that current version is not in conflict with published releases."""

from iminuit._parse_version import parse_version
from packaging.version import Version
import subprocess as subp
from pathlib import PurePath
import urllib.request
Expand All @@ -9,37 +9,32 @@
import sys


def version_string(v):
return ".".join(map(str, v))


project_dir = PurePath(__file__).parent.parent
changelog_fn = project_dir / "doc/changelog.rst"
version_fn = project_dir / "version.py"

version = subp.check_output([sys.executable, version_fn]).strip().decode()

with warnings.catch_warnings(record=True) as record:
iminuit_version = parse_version(version)
iminuit_version = Version(version)
if record:
raise ValueError(record[0].message)

iminuit_version_string = version_string(iminuit_version)
print("iminuit version:", iminuit_version_string)
print("iminuit version:", iminuit_version)

# make sure that changelog was updated
with open(changelog_fn) as f:
assert iminuit_version_string in f.read(), "changelog entry missing"
assert iminuit_version.base_version in f.read(), "changelog entry missing"

# make sure that version is not already tagged
tags = subp.check_output(["git", "tag"]).decode().strip().split("\n")
assert f"v{iminuit_version_string}" not in tags, "tag exists"
assert f"v{iminuit_version}" not in tags, "tag exists"

# make sure that version itself was updated
with urllib.request.urlopen("https://pypi.org/pypi/iminuit/json") as r:
pypi_versions = [parse_version(v) for v in json.loads(r.read())["releases"]]
pypi_versions = [Version(v) for v in json.loads(r.read())["releases"]]

pypi_versions.sort()
print("PyPI version:", version_string(pypi_versions[-1]))
print("PyPI version:", pypi_versions[-1])

assert iminuit_version not in pypi_versions, "pypi version exists"
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
python-version: '3.11'

- if: ${{ github.ref == 'refs/heads/main' }}
run: python .ci/release_check.py
run: |
pip install packaging
python .ci/release_check.py
- id: tag
run: echo "tag=$(python version.py)" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 3821654

Please sign in to comment.