-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 2.29 KB
/
Copy pathpublish-python.yaml
File metadata and controls
68 lines (59 loc) · 2.29 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
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@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
- 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@v4
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@v4
with:
name: sealg-dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1