Skip to content

Commit ee265b5

Browse files
leliaclaude
andcommitted
ci: require pyproject.toml and __init__.py versions to agree
The version lives as two hand-maintained literals with nothing deriving one from the other: pyproject.toml is what gets published, and __init__.py is what the CLI reports as its User-Agent. Every comparison in this job read only __init__.py, so bumping that alone passed the check and then published under the old number -- surfacing late, as twine rejecting an existing file, after the merge. Both are now required to match before any other comparison runs. uv.lock carries a third copy, but uv derives it and `uv lock --locked` in python-tests already fails when it drifts, so it needs no check here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b80cb01 commit ee265b5

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/version-check.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,33 @@ jobs:
4848
python3 <<'PY'
4949
import json
5050
import os
51+
import tomllib
5152
import urllib.request
5253
from packaging import version
5354
5455
pr_ver = version.parse(os.environ["PR_VERSION"])
5556
main_ver = version.parse(os.environ["MAIN_VERSION"])
5657
58+
with open("pyproject.toml", "rb") as fh:
59+
pyproject_ver = version.parse(tomllib.load(fh)["project"]["version"])
60+
61+
# The version is two hand-maintained literals with nothing deriving one
62+
# from the other: pyproject.toml is what actually gets published, and
63+
# socketsecurity/__init__.py is what the CLI reports as its User-Agent.
64+
# Every comparison below reads only __init__.py, so bumping that alone
65+
# would pass this job and then publish under the old number -- caught
66+
# late, by twine rejecting an existing file, after the merge. Require
67+
# the two to agree before comparing anything. (uv.lock carries a third
68+
# copy, but uv derives it and `uv lock --locked` in python-tests
69+
# already fails when it drifts.)
70+
if pr_ver != pyproject_ver:
71+
print(
72+
f"❌ Version mismatch inside the PR: pyproject.toml is "
73+
f"{pyproject_ver}, socketsecurity/__init__.py is {pr_ver}. "
74+
f"Bump both."
75+
)
76+
raise SystemExit(1)
77+
5778
with urllib.request.urlopen("https://pypi.org/pypi/socketsecurity/json") as response:
5879
pypi_data = json.load(response)
5980

0 commit comments

Comments
 (0)