Repository navigation
70 lines (61 loc) · 2.56 KB
/
Copy pathpublish-python.yaml
File metadata and controls
70 lines (61 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Publish Python (sealg)
# Publishes the Python `sealg` package (python/) to PyPI so `uvx sealg` resolves.
#
# Trigger: push a tag `sealg-py-vX.Y.Z` (pre-releases: `sealg-py-vX.Y.Z-rc.1`).
# The Python package versions independently of the Rust binary (which releases on
# `vX.Y.Z` via release.yml), so it gets its own tag namespace - a Rust release
# never republishes the Python package and vice versa.
#
# Auth is PyPI Trusted Publishing (OIDC): no API token is stored. One-time setup
# on PyPI is required before the first run - see RELEASING.md ("Publish the
# Python client").
on:
push:
tags:
- "sealg-py-v[0-9]+.[0-9]+.[0-9]+"
- "sealg-py-v[0-9]+.[0-9]+.[0-9]+-*"
# Manual build-only run to validate packaging without publishing.
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Install uv
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
version: "0.13.5"
- name: Verify tag matches package version
# Only enforced on tag pushes; skipped for workflow_dispatch (build-only).
if: startsWith(github.ref, 'refs/tags/')
run: |
tag_ver="${GITHUB_REF_NAME#sealg-py-v}"
pkg_ver="$(python3 -c 'import tomllib,pathlib; print(tomllib.loads(pathlib.Path("python/pyproject.toml").read_text())["project"]["version"])')"
if [ "$tag_ver" != "$pkg_ver" ]; then
echo "::error::tag $GITHUB_REF_NAME implies version '$tag_ver' but python/pyproject.toml is '$pkg_ver'. Bump the version before tagging."
exit 1
fi
echo "tag and package agree on version $pkg_ver"
- name: Build sdist + wheel
run: uv build python/ --out-dir dist
- name: Upload artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: sealg-dist
path: dist/
publish:
# Tag pushes publish; the manual build-only run stops after `build`.
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # OIDC token for PyPI Trusted Publishing
steps:
- name: Download artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: sealg-dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3