Skip to content

Auto-publish to PyPI on release (Trusted Publishing)#59

Merged
itg-karthicr merged 2 commits into
masterfrom
ci/pypi-publish
Jun 24, 2026
Merged

Auto-publish to PyPI on release (Trusted Publishing)#59
itg-karthicr merged 2 commits into
masterfrom
ci/pypi-publish

Conversation

@itg-karthicr

Copy link
Copy Markdown
Contributor

Closes #58

Summary

Auto-publishes pystrix to PyPI when a GitHub release is published, using PyPI Trusted Publishing (OIDC) — no API token is stored in the repo or CI.

Workflow (.github/workflows/publish.yml)

  • Triggers on release: published.
  • Builds the sdist + wheel with python -m build, then uploads via pypa/gh-action-pypi-publish using OIDC.
  • contents: read at the top level; the publish job requests id-token: write (needed for OIDC) and runs in a pypi GitHub Environment.

Security

No untrusted input is used in any run: step; the only privilege is id-token: write scoped to the publish job. The trigger is release: published, which only a maintainer can fire.

Required one-time setup (maintainer, on PyPI)

Add a Trusted Publisher to the existing pystrix PyPI project:

  • Owner: IVRTech
  • Repository: pystrix
  • Workflow: publish.yml
  • Environment: pypi

This requires owner/maintainer access to the existing pystrix PyPI project. Until it's configured, the publish job will fail at the upload step with an auth error (re-runnable once set up).

Optionally, add a required reviewer to the pypi GitHub Environment (repo settings) to gate each publish behind a manual approval.

Sequence to ship 1.3.0

  1. Merge this PR.
  2. Merge the release PR (Release 1.3.0 #57).
  3. Configure the PyPI Trusted Publisher (above).
  4. Tag v1.3.0 and publish the GitHub release — the workflow then builds and uploads automatically.

🤖 Generated with Claude Code

A publish.yml workflow builds the sdist + wheel and uploads to PyPI when
a GitHub release is published. Authentication is PyPI Trusted Publishing
(OIDC) -- no API token is stored. The publish job requests id-token:write
and runs in a 'pypi' GitHub Environment, which also allows an optional
manual-approval gate.

Requires a one-time PyPI Trusted Publisher config (owner IVRTech, repo
pystrix, workflow publish.yml, environment pypi).

Closes #58
- Split into an unprivileged `build` job and an OIDC `publish` job
  (needs: build), passing dist/ via artifact. Only the publish job holds
  id-token: write, so the build backend never has the publishing identity
  (PyPA-recommended structure).
- Add contents: read to the publish job's permissions (job-level perms do
  not inherit the top-level block).
- Add a verify step: non-empty dist/, twine check, and a built-version vs
  release-tag match (read from an env var to avoid injection).

Kept pypa/gh-action-pypi-publish@release/v1 (PyPA's recommended ref)
rather than a SHA pin; SHA-pinning is deferred to pair with Dependabot.
@itg-karthicr itg-karthicr merged commit 5edbbd2 into master Jun 24, 2026
8 checks passed
@itg-karthicr itg-karthicr deleted the ci/pypi-publish branch June 24, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-publish to PyPI on release (Trusted Publishing)

1 participant