Authenticate to PyPI, npm, and GitHub#
This guide shows you how to set up the credentials a release needs. It covers trusted publishing for PyPI and npm, tokens for repoplone, and the GitHub token.
Credential |
Needed when |
|---|---|
PyPI |
a Python package is published |
npm |
a Node package is published |
GitHub |
the release creates a GitHub release |
Publish with trusted publishing#
PyPI and npm both recommend trusted publishing. A GitHub Actions workflow proves its identity to the registry, and gets a short-lived credential for one upload. No long-lived token is stored on a computer or in the repository.
With trusted publishing, repoplone release prepares the release, and a workflow publishes it.
Set
publish = falseon each package inrepository.toml.[[package]] type = "python" name = "my.package" path = "." changelog = "CHANGELOG.md" publish = false
repoplone releasestill sets the version, builds the changelog, tags the release, and creates the GitHub release. It no longer uploads the package. It no longer needs PyPI or npm credentials either.Register the workflow as a trusted publisher. On PyPI, add it in the publishing settings of the project. On npm, add it in the settings of the package. Each registry asks for the repository, the workflow file name, and optionally a GitHub environment.
Add a workflow that publishes when a GitHub release is published. The job that uploads needs the
id-token: writepermission.name: Release on: release: types: - published permissions: contents: read jobs: publish: runs-on: ubuntu-latest environment: release permissions: id-token: write steps: - uses: actions/checkout@v7 with: ref: ${{ github.event.release.tag_name }} - uses: astral-sh/setup-uv@v7 - run: uv build - uses: pypa/gh-action-pypi-publish@release/v1
For a Node package, run
npm publishin the package folder from a job with the same permission. npm trusted publishing requires npm 11.5.1 or later, and Node 22.14.0 or later.
repoplone publishes itself this way. Its release workflow also accepts a tag by hand, to retry a failed upload.
Note
GitHub starts no workflow for a release created with the GITHUB_TOKEN of another workflow.
Run repoplone release from your computer with a personal token, or trigger the publishing workflow on the tag instead.
Let repoplone publish to PyPI#
To have repoplone upload a Python package itself, keep publish = true and give it a token.
Create an API token in your PyPI account settings, scoped to the project when it already exists.
Export it before you release.
export UV_PUBLISH_TOKEN="pypi-your-token"
uv publish uploads with this token.
repoplone also accepts a token stored for pypi.org with uv auth login.
Without either, the release stops with You are not authenticated to PyPi using UV.
Let repoplone publish to npm#
To have repoplone release a Node package with release-it, keep publish = true and log in to the npm registry.
npm login
repoplone runs npm whoami to check the login.
release-it then publishes with the same credentials.
GitHub#
Create a token that can create releases in the repository. A fine-grained token needs the Contents permission set to Read and write. Export it before you release.
export GITHUB_TOKEN="github_pat_your-token"
Without GITHUB_TOKEN, repoplone offers to use the token of the GitHub CLI, gh, when you run it in a terminal.
Without any token, it warns before the release and skips the GitHub release.
See also
Environment variables and external tools, for every variable and command repoplone uses.
Release a repository, to run the release.