Publish to PyPI via Trusted Publishing - #28
Merged
Conversation
The v0.3.0 release built fine but `twine upload` was rejected with `403 Forbidden`: the workflow authenticates with the `PYPI_USERNAME` / `PYPI_PASSWORD` secrets stored in 2024, and those credentials no longer work. Switch to Trusted Publishing, so GitHub mints a short-lived OIDC credential for this workflow and there is no long-lived secret to expire or leak. Requires registering the publisher once on PyPI (Manage project -> Publishing) with owner `doronz88`, repository `DeveloperDiskImage`, workflow `python-publish.yml` and no environment. Also add a `workflow_dispatch` trigger taking a tag, so a release whose publish run failed can be retried without cutting a new version, and fetch the full history since setuptools_scm derives the version from tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The v0.3.0 release built fine but
twine uploadwas rejected with 403 Forbidden. The workflow authenticates with thePYPI_USERNAME/PYPI_PASSWORDsecrets stored in 2024-11, and those credentials no longer work — so v0.3.0 is tagged and released on GitHub but absent from PyPI.Rather than rotating another long-lived token, this switches to Trusted Publishing: GitHub mints a short-lived OIDC credential scoped to this workflow, so there is no secret to expire or leak.
PYPI_USERNAME/PYPI_PASSWORDcan be deleted from the repository secrets afterwards.Also:
workflow_dispatchtaking a tag, so a release whose publish run failed can be retried without cutting a new version.fetch-depth: 0, since setuptools_scm derives the version from tags.checkout/setup-pythonactions off v3/v4.One-time setup required before this can publish
On PyPI →
developer-disk-image→ Manage → Publishing → Add a new publisher (GitHub):doronz88DeveloperDiskImagepython-publish.ymlOnce that exists, re-publishing v0.3.0 is Actions → Upload Python Package → Run workflow →
v0.3.0.