Skip to content
Merged
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
23 changes: 16 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,33 @@ jobs:
- name: Install build tools
run: python -m pip install --upgrade build twine

- name: Validate release tag
- name: Validate release tag references package version
if: github.event_name == 'release'
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<"PY"
python - <<'PY'
import os
import pathlib
import re
import tomllib

with open("pyproject.toml", "rb") as file:
project = tomllib.load(file)

project = tomllib.loads(pathlib.Path("pyproject.toml").read_text())
version = project["project"]["version"]
release_tag = os.environ["RELEASE_TAG"]
if release_tag != f"v{version}":
version_tokens = {
token
for token in re.split(r"[-+_/]", release_tag)
if token
}

if version not in version_tokens and f"v{version}" not in version_tokens:
raise SystemExit(
f"Release tag {release_tag!r} does not match version {version!r}."
f"Release tag {release_tag!r} does not reference pyproject "
f"version {version!r}."
)

print(f"Building distributions for version {version}")
PY

- name: Build and check distributions
Expand Down
Loading