- With an authenticated client. This approach is recommended for teams that publish packages from development machines, or that are using CI/CD systems that do not (yet) support Trusted Publishing.
- With Trusted Publishing. This approach is recommended for teams that publish packages from GitHub Actions and other supported CI/CD systems.
Publishing with an authenticated client
Once authenticated, you can publish packages to your team’s dedicated private registry. For example, if your team is calledacme
, you can publish packages to the
acme/main
index with:
pyproject.toml
:
Use
uv publish --dry-run
to validate your distribution prior to writing to
the registry.pyproject.toml
lets you omit the URLs from the
command line:
main
index is created by default during onboarding. If you need to create
additional indexes, don’t hesitate to get in touch.
You can browse uploaded packages in the pyx dashboard, or
by querying the Simple API:
Trusted Publishing
Trusted Publishing is currently in beta. All organizations have access to it,
but you may encounter bugs or missing features. If you have feedback, please
get in touch.
- Usability: with Trusted Publishing, there’s no need to create and provision API tokens on your CI/CD system. The CI/CD system can authenticate directly to pyx.
- Security: Trusted Publishing uses short-lived credentials that are minimally scoped (down to the exact set of packages configured for publishing). These qualities reduce the blast radius of a compromised credential.
Supported Trusted Publishing providers
At the moment, pyx supports Trusted Publishing with the following CI/CD providers:- GitHub Actions
- GitLab CI/CD (coming soon)
At the moment, support for these providers is limited to their hosted
offerings (e.g.,
github.com
). Support for self-hosted instances is not yet
available.Enrolling a Trusted Publisher
You can enroll a Trusted Publisher against one or more of your team’s packages in the in the pyx dashboard under Team > Trusted Publishers.At the moment, only team administrators can enroll Trusted Publishers.
- GitHub Actions
A GitHub Actions Trusted Publisher has three components:
-
The Repository is the
owner/repo
slug on GitHub from which you’ll be publishing. -
The Workflow is the filename of the GitHub Actions workflow
that will be publishing. This should be the base filename, e.g.,
publish.yml
(not.github/workflows/publish.yml
). -
The Environment is the optional name of the
GitHub Actions environment
that will be used for publishing. This environment must be configured
in the GitHub repository settings and must be used in the workflow
via
environment: <name>
.Specifying an environment is optional, but recommended: environments enable you to enforce additional protections, like required reviewers and tag protection rules on your publishing workflow.
Publishing with a Trusted Publisher
Once you’ve enrolled a Trusted Publisher against one or more packages, you can publish to pyx with it.- GitHub Actions
On GitHub Actions, we recommend that you use
astral-sh/pyx-auth-action.
An example job definition is given below.
For isolation reasons, we strongly recommend that you perform
your distribution build in a separate job that your publishing job
depends on. This ensures that your build environment does not have
access to the short-lived credentials used for publishing.
Private classifiers
pyx supports private classifiers, which you can use to prevent packages from being accidentally published to PyPI (or another index) instead of pyx. Private classifiers come in two forms:Private :: pyx
allows publishing anywhere on pyx (but only to pyx).Private :: pyx :: <team>
restricts publishing to a specific team. For example,Private :: pyx :: acme
allows publishing only to theacme
team’s registries.
pyproject.toml
. For example:
Like PyPI, pyx will reject packages that use the
Private :: Do Not Upload
classifier. Additionally, like PyPI, pyx will reject any Private ::
classifiers not recognized by the rules above.Twine support
pyx supports publishing from non-uv clients, liketwine
. To publish with twine
,
point the twine
client to the pyx index, and authenticate via
uv auth token pyx.dev
: