Skip to content

Publish to PyPI via Trusted Publishing - #28

Merged
doronz88 merged 1 commit into
mainfrom
bugfix/trusted-publishing
Aug 7, 2026
Merged

Publish to PyPI via Trusted Publishing#28
doronz88 merged 1 commit into
mainfrom
bugfix/trusted-publishing

Conversation

@doronz88

@doronz88 doronz88 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

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-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_PASSWORD can be deleted from the repository secrets afterwards.

Also:

  • workflow_dispatch taking 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.
  • Bumped the checkout / setup-python actions off v3/v4.

One-time setup required before this can publish

On PyPI → developer-disk-image → Manage → Publishing → Add a new publisher (GitHub):

Field Value
Owner doronz88
Repository name DeveloperDiskImage
Workflow name python-publish.yml
Environment name (leave empty)

Once that exists, re-publishing v0.3.0 is Actions → Upload Python Package → Run workflow → v0.3.0.

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.
@doronz88
doronz88 merged commit 5423e4e into main Aug 7, 2026
15 checks passed
@doronz88
doronz88 deleted the bugfix/trusted-publishing branch August 7, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant