ci: add PyPI publish workflow on tag v* (uses trusted publishing, no token)
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
name: build wheel + sdist and publish to PyPI
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: pypi
|
||||||
|
url: https://pypi.org/p/invisible-playwright
|
||||||
|
permissions:
|
||||||
|
id-token: write # required for PyPI trusted publishing
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
|
||||||
|
- name: Install build deps
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install build twine
|
||||||
|
|
||||||
|
- name: Build wheel + sdist
|
||||||
|
run: python -m build
|
||||||
|
|
||||||
|
- name: Check wheel has no duplicate zip entries
|
||||||
|
run: |
|
||||||
|
python - <<'EOF'
|
||||||
|
import zipfile, sys
|
||||||
|
from collections import Counter
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
wheels = list(Path("dist").glob("*.whl"))
|
||||||
|
assert len(wheels) == 1, wheels
|
||||||
|
with zipfile.ZipFile(wheels[0]) as zf:
|
||||||
|
dupes = {n: c for n, c in Counter(zf.namelist()).items() if c > 1}
|
||||||
|
if dupes:
|
||||||
|
print("DUPLICATE ENTRIES IN WHEEL:", dupes)
|
||||||
|
sys.exit(1)
|
||||||
|
print("wheel is clean:", wheels[0].name)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Validate metadata with twine
|
||||||
|
run: twine check dist/*
|
||||||
|
|
||||||
|
- name: Publish to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
Reference in New Issue
Block a user