this_file: README.md
pypitrust
One command takes a GitHub repo from "has a pyproject.toml" to "pushing a v* tag publishes it to PyPI". No API token is stored anywhere: publishing uses PyPI Trusted Publishing (OIDC).
uv tool install pypitrust
pypitrust setup octo/my-pkg # owner/name, a GitHub URL, or a local clone
pypitrust setup octo/my-pkg --dry_run # show what would change
pypitrust setup octo/my-pkg --test_pypi # rehearse on test.pypi.org
pypitrust setup repos.txt # many repos, resumable
pypitrust upgrade ~/src/my-pkg # write the release files into a clone
pypitrust workflow my-pkg # print the workflow it would commit
pypitrust config # show the settings in effect
What setup does
- GitHub, through your logged-in
ghCLI:- creates the deployment environment (default
pypi); - commits
.github/workflows/release.ymlunless you pass--skip_workflow. An existing file is never overwritten; you get a warning if it lacksid-token: write.
- creates the deployment environment (default
- PyPI, through a real Chrome driven by playwrightauthor:
- if the project exists, adds a trusted publisher in its Publishing settings;
- if it doesn't, adds a pending publisher to your account, so the first release creates the project.
- It's idempotent: a matching publisher is detected and left alone, and a new one is checked once PyPI lists it.
PyPI has no API for trusted-publisher settings (warehouse#14456), which is why a browser is involved. If PyPI asks you to log in or to confirm your password (its hourly sudo mode), do it in the window that opens, 2FA included. The tool waits, then continues. It never types your password. The browser profile keeps the session for later runs.
The release setup
pypitrust upgrade PATH writes these into a local clone and commits nothing:
.github/workflows/release.yml: on av*tag push, or a manual dispatch with ataginput, the jobs run in order:- create the tag (dispatch only);
uv buildfrom that tag, checking the built version matches it;- create a GitHub Release with the files;
- publish to PyPI over OIDC from the protected environment.
publish.sh: picks the next patch tag (or takesvX.Y.Z) and dispatches the workflow.build.sh:uv build, added only when missing..gitignore: gets the hatch-vcs version file (for examplesrc/pkg/__version__.py), which is also untracked, so CI never builds a+dirtyversion.
It warns about other workflows that still publish with a token. Then run pypitrust setup OWNER/REPO --skip_workflow to register the publisher.
Versions come from git tags via hatch-vcs. Your pyproject.toml needs:
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
dynamic = ["version"]
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/my_pkg/__version__.py"
Repos whose wheels are built on your machine (maturin, several packages per repo) use pypitrust upload-helper PATH instead. It adds scripts/pypi-upload.sh FILE..., which attaches the files to a draft GitHub release, dispatches .github/workflows/pypi-upload.yml and waits for the upload. Drafts create no git tag, so tag-derived versions stay put. Register that workflow with --workflow pypi-upload.yml.
Many repos at once
Give setup a text file instead of a repo. Each line holds one job, REPO [PACKAGE|-] [WORKFLOW], and # starts a comment:
octo/alpha # package name read from pyproject.toml
https://github.com/octo/beta beta
acme/gamma - pypi-upload.yml
Each job runs four steps: package, github_env, workflow, pypi_publisher. Every outcome goes into repos.txt.status.json (or the file --status names), so running the same command again skips finished steps.
- A step skipped with
--skip_pypior--skip_workflowstays pending and runs on a later full run. - A failed step stops only its own job;
--retry_failedtries it again. - PyPI registrations are spaced
delayseconds apart. - PyPI rate-limits registrations. On a 429 the whole run pauses for
cooldownseconds, records the pause in the status file and exits 75 (EX_TEMPFAIL). Before then, running it again does nothing.
Configuration
Settings come from the built-in defaults, then a TOML config file, then command-line flags. The first config file found wins: --config PATH, $PYPITRUST_CONFIG, ./pypitrust.toml, [tool.pypitrust] in ./pyproject.toml, and $XDG_CONFIG_HOME/pypitrust/config.toml (~/.config/...). Unknown keys and wrong types are errors. pypitrust.example.toml lists every key:
| key | default | meaning |
|---|---|---|
environment |
"pypi" |
GitHub environment the workflow publishes from |
workflow |
"release.yml" |
workflow filename registered with PyPI |
test_pypi |
false |
target test.pypi.org |
profile |
"default" |
playwrightauthor browser profile |
debug_port |
unset | Chrome CDP port, when another Chrome already holds the default |
login_timeout |
300 |
seconds to wait for a manual login |
action_timeout |
30 |
seconds per browser action |
delay |
90 |
list runs: seconds between registrations |
cooldown |
3600 |
list runs: pause after a 429 |
Run-only flags: --package, --dry_run, --skip_pypi, --skip_workflow, --retry_failed, --status, --verbose.
Caveats
- A pending publisher is void if someone else registers the name first, so register early.
- When PyPI shows an error page, the tool stops and leaves the browser as it is, rather than retrying blindly.
Development
uv sync
uv run pytest
./build.sh # version from the latest tag
./publish.sh # release the next patch version
pypitrust releases itself with the setup it writes. CI runs ruff and the tests on Python 3.12 and 3.13.
Licence
Apache-2.0
Metadata
Release files for pypitrust 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypitrust-1.0.2.tar.gz | 28.8 kB | With provenance | Details for pypitrust-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypitrust-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for pypitrust-1.0.2-py3-none-any.whl |
Total release size: 58.5 kB
Release files / pypitrust-1.0.2.tar.gz
| Download URL | pypitrust-1.0.2.tar.gz |
|---|---|
| Size | 28.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24cd52da3fc384dd2870aa0b80b87d6ed02ad1dab4da8f50a9c1f7ce8a717402
|
|
BLAKE2b-256 checksum How to use checksums |
80b540dbbb92af31256ca3dec86692ec8af162a6871f30c2f7802d1f6dd57c79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / pypitrust-1.0.2-py3-none-any.whl
| Download URL | pypitrust-1.0.2-py3-none-any.whl |
|---|---|
| Size | 29.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb0d1166d70711c53222ac6e7064b5428f738aec14f090db3791fb25edd5476d
|
|
BLAKE2b-256 checksum How to use checksums |
dfebf998779bae2e27b44e4fadbcb8182a426bbdbce3ba40e1c1705754a2f094
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for pypitrust 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pypitrust-1.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.