Skip to content

ci: Publish to PyPI without a stored API token - #370

Merged
emyller merged 4 commits into
mainfrom
ci/pypi-trusted-publishing
Dec 1, 2026
Merged

emyller merged 4 commits into
mainfrom
ci/pypi-trusted-publishing

Conversation

@emyller

@emyller emyller commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes ENG-1112.

Releases reach PyPI using a long-lived API token stored as a repository secret: whoever obtains it can publish flagsmith-flag-engine at will until someone revokes it by hand. PyPI now trusts this repository's publish workflow directly, so each release authenticates with a short-lived credential issued for that run, and no secret is stored.

Changes

  • Releases authenticate to PyPI as a trusted publisher instead of with a stored API token.
  • The package is built separately from the step that is allowed to publish, as in flagsmith-python-client.
  • The publish workflow's GitHub token is limited to reading the repository.
  • After the first release published this way, revoke the PyPI API token and delete the PYPI_API_TOKEN secret.

The workflow file is renamed to publish.yml because that is the filename PyPI's trusted publisher is bound to. It only runs on a release tag, so it stays unexercised until the next release.

Review effort: 2/5

🤖 Generated with Claude Code

Authenticate releases as a PyPI trusted publisher (OIDC) instead of the long-lived PYPI_API_TOKEN secret. The workflow is renamed to publish.yml, the filename PyPI trusts, and the build runs in a job that holds no publishing rights.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@emyller
emyller requested a review from a team as a code owner November 30, 2026 22:26
@emyller
emyller requested review from khvn26 and removed request for a team November 30, 2026 22:26
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

File Coverage Missing
All files 100% ✅

Minimum allowed coverage is 100%

Generated by 🐒 cobertura-action against 6b99f43

@codspeed

codspeed Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 1 untouched benchmark


Comparing ci/pypi-trusted-publishing (6b99f43) with main (30b3d3d)

Open in CodSpeed

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread .github/workflows/publish.yml Resolved

@khvn26 khvn26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question

Comment thread .github/workflows/publish.yml Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread .github/workflows/publish.yml Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Revamps the PyPI release workflow from a stored API token to OIDC trusted publishing, splitting build and publish and tightening tag/permission scopes. The credential and deployment autentication change needs human verification of PyPI trust configuration and the token-revocation follow-up.

Turn on auto-fix | Re-trigger cubic

@emyller
emyller requested a review from khvn26 December 1, 2026 14:28
@emyller
emyller merged commit ff96017 into main Dec 1, 2026
9 checks passed
@emyller
emyller deleted the ci/pypi-trusted-publishing branch December 1, 2026 14:28
emyller pushed a commit that referenced this pull request Dec 1, 2026
🤖 I have created a release *beep* *boop*
---


## [11.1.3](v11.1.2...v11.1.3) (2026-12-01)


### CI

* Publish to PyPI without a stored API token ([#370](#370)) ([ff96017](ff96017))


### Dependency Updates

* update dependency black to v26.10.1 [security] ([#361](#361)) ([cc63b46](cc63b46))
* update dependency datamodel-code-generator to v0.81.0 [security] ([#351](#351)) ([30b3d3d](30b3d3d))


### Other

* remove release-please workflow ([#368](#368)) ([3e7084c](3e7084c))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants