Skip to content

0.7.0

0.7.0 #13

Workflow file for this run

name: Upload Python Package
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install build dependencies
run: python -m pip install build
- name: Build release distributions
run: python -m build
- name: Validate release version
if: github.event_name == 'release'
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_NAME: ${{ github.event.release.name }}
run: |
python - <<'PY'
import email.parser
import os
import re
import sys
import zipfile
from pathlib import Path
def normalize(value):
match = re.search(r"\d+(?:\.\d+)+(?:[-+._a-zA-Z0-9]*)?", value or "")
return match.group(0).lstrip("vV") if match else ""
expected = normalize(os.environ.get("RELEASE_TAG")) or normalize(os.environ.get("RELEASE_NAME"))
wheels = sorted(Path("dist").glob("*.whl"))
if not wheels:
print("No wheel found in dist/.", file=sys.stderr)
sys.exit(1)
with zipfile.ZipFile(wheels[0]) as wheel:
metadata_name = next(name for name in wheel.namelist() if name.endswith(".dist-info/METADATA"))
metadata = email.parser.Parser().parsestr(wheel.read(metadata_name).decode("utf-8"))
built = metadata["Version"]
if built != expected:
print(
f"Release version mismatch: GitHub release expects {expected!r}, "
f"but the built package is {built!r}. Update lumisync.__version__ "
"or publish a release that matches the package version.",
file=sys.stderr,
)
sys.exit(1)
print(f"Release version OK: {built}")
PY
- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: release-dists
path: dist/
pypi-publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/project/lumisync/${{ github.event.release.name }}
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v8
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true