Skip to content

Commit e2dc05f

Browse files
ci: add publish-on-tag workflow (PyPI trusted publishing)
Fires on a semver tag, verifies pyproject.toml version matches the tag, builds sdist+wheel, and publishes via PyPI Trusted Publishing (OIDC). No long-lived API token stored. To activate: configure the trusted publisher on PyPI under Project settings → Publishing → Add a new publisher → GitHub, pointing at this repo's publish.yml in the 'pypi' environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7c7ebfe commit e2dc05f

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to PyPI
2+
3+
# Fires on a semver tag (v0.2.0, v1.0.0-prod, etc.). The job builds the wheel +
4+
# sdist and publishes via PyPI Trusted Publishing (OIDC). No long-lived API token
5+
# is stored — the trusted publisher must be configured on PyPI under:
6+
# Project settings → Publishing → Add a new publisher → GitHub
7+
# owner: mizcausevic-dev
8+
# repository: aeo-sdk-python
9+
# workflow filename: publish.yml
10+
# environment: pypi
11+
#
12+
# If you prefer a token-based flow, add a PYPI_API_TOKEN secret and replace
13+
# the gh-action-pypi-publish step with:
14+
# with:
15+
# password: ${{ secrets.PYPI_API_TOKEN }}
16+
17+
on:
18+
push:
19+
tags:
20+
- "v*"
21+
22+
permissions:
23+
contents: read
24+
id-token: write # required for trusted publishing
25+
26+
jobs:
27+
build-and-publish:
28+
runs-on: ubuntu-latest
29+
environment:
30+
name: pypi
31+
url: https://pypi.org/project/aeo-protocol/
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
37+
- name: Install build deps
38+
run: python -m pip install --upgrade pip build
39+
- name: Build sdist + wheel
40+
run: python -m build
41+
- name: Verify tag matches pyproject.toml version
42+
run: |
43+
TAG="${GITHUB_REF_NAME#v}"
44+
PKG_VERSION=$(grep '^version = ' pyproject.toml | head -1 | cut -d '"' -f2)
45+
if [ "$TAG" != "$PKG_VERSION" ]; then
46+
echo "::error::Git tag ($TAG) does not match pyproject.toml version ($PKG_VERSION)"
47+
exit 1
48+
fi
49+
- name: Publish to PyPI (trusted publishing)
50+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)