Skip to content

ci: publish to PyPI via trusted publishing instead of an API token - #96

Merged
ryanhill1 merged 3 commits into
mainfrom
ci/pypi-trusted-publishing
Aug 24, 2026
Merged

ci: publish to PyPI via trusted publishing instead of an API token#96
ryanhill1 merged 3 commits into
mainfrom
ci/pypi-trusted-publishing

Conversation

@ryanhill1

@ryanhill1 ryanhill1 commented Aug 24, 2026

Copy link
Copy Markdown
Member

Matches qBraid/qBraid#1346, which does the same for the SDK.

The publish workflows authenticated to PyPI with PYPI_API_TOKEN, a long-lived
credential stored as a repository secret. This switches them to Trusted Publishing:
the job requests id-token: write, and pypa/gh-action-pypi-publish mints a
short-lived OIDC credential scoped to that one workflow. No publishing secret is
stored in the repository afterwards.

Trusted Publishing is also the prerequisite for PEP 740 attestations, which the
action generates by default. Those attach the repository, workflow and commit SHA
to each uploaded file, so a published wheel can be traced back to the commit that
built it. They apply to releases published after this merges, not retroactively.

Requires action before the next release. A trusted publisher must be registered
on the PyPI project settings naming this repository, the workflow filename, and the
environment, or publishing will fail rather than fall back to the token. The
PYPI_API_TOKEN secret can be deleted once a release has gone out successfully.

TestPyPI workflows are left on their existing token, since that registry needs its
own separate publisher configuration.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated package publishing workflows to use secure, tokenless authentication with PyPI trusted publishing.
    • Added the required permissions for automated releases and pre-releases.

@argus-eye

argus-eye Bot commented Aug 24, 2026

Copy link
Copy Markdown

Argus review

Auto-review is off for this repo. Tick the box below to run a review on this PR.

  • Trigger Argus review

Estimated cost

  • Files changed: 2
  • Diff lines (±): 11

Tip: you can also comment @argus-eye review at any time.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d010020-21f1-4472-974a-e87ca1a5c158

📥 Commits

Reviewing files that changed from the base of the PR and between f356b45 and 9f4ae85.

📒 Files selected for processing (2)
  • .github/workflows/pre-release.yml
  • .github/workflows/publish.yml

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting


Walkthrough

The pre-release and publish workflows now use GitHub OIDC trusted publishing for PyPI. Both pypi-publish jobs grant id-token: write and contents: read. The pre-release step removes API token credentials.

Changes

PyPI OIDC publishing

Layer / File(s) Summary
Configure trusted publishing authentication
.github/workflows/pre-release.yml, .github/workflows/publish.yml
Both pypi-publish jobs declare id-token: write and contents: read. The pre-release publish step no longer passes PYPI_API_TOKEN credentials.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseWorkflow
  participant GitHubOIDC
  participant PyPI
  ReleaseWorkflow->>GitHubOIDC: Request OIDC token
  GitHubOIDC-->>ReleaseWorkflow: Return identity token
  ReleaseWorkflow->>PyPI: Publish package with OIDC identity
Loading
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/pypi-trusted-publishing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ryanhill1
ryanhill1 merged commit 64feffc into main Aug 24, 2026
8 of 9 checks passed
@ryanhill1
ryanhill1 deleted the ci/pypi-trusted-publishing branch August 24, 2026 22:47
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.

1 participant