Skip to content

Commit e7961e1

Browse files
petercorkeclaude
andcommitted
ci: add PyPI trusted-publish workflow, manual docs dispatch
Adds .github/workflows/publish.yml: on a published GitHub Release, build sdist+wheel from the release tag, check metadata with twine, and publish to PyPI via pypa/gh-action-pypi-publish using OIDC trusted publishing (permissions: id-token: write) -- no stored token/secret. Scoped to a "pypi" GitHub Environment so PyPI's trusted-publisher check is exact (repo + workflow + environment) and so manual-approval gating can be added later if wanted. Requires a one-time manual step on PyPI: add a trusted publisher on the existing pgraph-python project (Settings -> Publishing) naming this repo, workflow filename, and the "pypi" environment. Also adds workflow_dispatch to ci.yml's triggers, and widens the docs job's condition to run on manual dispatch as well as push, so the Sphinx docs can be manually rebuilt/redeployed on demand without any relationship to a PyPI release -- the two are on separate triggers entirely (push+dispatch for docs, release-published only for PyPI). Verified: pyproject.toml/publish.yml YAML parses; `python -m build` produces a clean sdist+wheel from this checkout; `twine check` passes on both; a genuinely isolated venv (confirmed via sys.prefix) installs the built wheel and successfully imports and exercises real functionality (UGraph/add_vertex/add_edge/__str__). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent cdbc54a commit e7961e1

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
workflow_dispatch:
89

910
jobs:
1011
unittest:
@@ -81,7 +82,7 @@ jobs:
8182
verbose: true
8283

8384
docs:
84-
if: github.event_name == 'push'
85+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
8586
needs: unittest
8687
runs-on: ubuntu-latest
8788
steps:

‎.github/workflows/publish.yml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
- name: Install build tooling
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install build twine
20+
- name: Build sdist and wheel
21+
run: python -m build
22+
- name: Check metadata
23+
run: twine check dist/*
24+
- name: Upload build artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: dist/
29+
30+
publish:
31+
needs: build
32+
runs-on: ubuntu-latest
33+
environment:
34+
name: pypi
35+
url: https://pypi.org/project/pgraph-python/
36+
permissions:
37+
id-token: write # required for PyPI trusted publishing (OIDC)
38+
steps:
39+
- name: Download build artifacts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: dist
43+
path: dist/
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)