Skip to content

xval-end-to-end

xval-end-to-end #92

Workflow file for this run

name: Build & Publish to PyPI (main)
on:
push:
branches: [ main ]
jobs:
build-and-publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Verify version is new on PyPI
run: |
python - <<'PY'
import json, sys, urllib.request, tomllib, pathlib
pp = pathlib.Path("UnitMatchPy/pyproject.toml")
data = tomllib.loads(pp.read_text(encoding="utf-8"))
current = data["project"]["version"]
pkg = data["project"]["name"]
latest = None
try:
with urllib.request.urlopen(f"https://pypi.org/pypi/{pkg}/json", timeout=10) as r:
info = json.load(r)
latest = info["info"]["version"]
except Exception:
pass
print(f"Current version: {current}; PyPI latest: {latest}")
if latest is not None and current == latest:
print(f"ERROR: {pkg} {current} already exists on PyPI. Bump [project].version in UnitMatchPy/pyproject.toml.", file=sys.stderr)
sys.exit(1)
PY
- name: Install build tool
run: python -m pip install --upgrade pip build
- name: Build sdist/wheel (subdir)
working-directory: UnitMatchPy
run: python -m build
- name: Publish to PyPI (OIDC)
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: UnitMatchPy/dist
# Optional: keep this if you want success even when you forgot the bump
# skip-existing: true