Replies: 1 comment
Benefits & Implementation Blueprint for Trusted Publishing in
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi there! Thanks for maintaining httpx.
I'm opening this up to see if there's appetite/interest among the httpx maintainers for switching the PyPI publishing process to Trusted Publishing: https://docs.pypi.org/trusted-publishers/
TL;DR: Trusted Publishing is a way to publish from CI/CD (like GitHub Actions) without long-lived credentials. It's already used by tens of thousands of packages on PyPI.
The main advantage to Trusted Publishing is that it doesn't require a manually configured credential in CI anymore, which means less credential exposure surface and operational churn. It also unblocks the ability to upload PEP 740 attestations for a package, since PEP 740 is established on top of the identities that Trusted Publishing uses internally.
In terms of the switch, I think httpx could do this pretty easily: you currently have a
publishscript that gets run from CI here:httpx/.github/workflows/publish.yml
Lines 25 to 26 in ae1b9f6
That script then invokes
twinedirectly here:httpx/scripts/publish
Line 25 in ae1b9f6
twinehas native support for Trusted Publishing as of 6.1.0, so switching should be as simple as removing your credentials from CI, configuring the publisher on PyPI, and addingid-token: writeto the CI job instead.Alternatively, you could use
uv publishorgh-action-pypi-publish, both of which also support Trusted Publishing.Alternatives
The main alternative is to do nothing! API tokens aren't bad or broken; Trusted Publishing is just an improvement over them for the CI setting.
The main downside (for some projects) to Trusted Publishing is that it's limited to CI, i.e. you can't do local publishes with it. This is intentional, but it may not fit your publishing pattern, in which case you may not want to adopt it. However, if you do prefer publishing from CI (which is generally recommended as an isolation measure), then Trusted Publishing is a good fit.
Prior art
There's a lot of prior art out there, but here's an example of black switching: psf/black#4611
There's also a full official guide from PyPA on publishing from GitHub here: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
All reactions