Skip to content

PyPI release workflow fails trusted publishing with invalid-publisher #7

@discolotus

Description

@discolotus

Bug: PyPI release workflow fails with invalid-publisher

The Publish to PyPI GitHub Actions workflow is currently configured to use PyPI Trusted Publishing, but release publishes fail during the OIDC token exchange.

Evidence

Latest release run:

Failure excerpt:

Trusted publishing exchange failure:
Token request failed: the server refused the request for the following reasons:

* `invalid-publisher`: valid token, but no corresponding publisher (Publisher with matching claims was not found)

GitHub/PyPI claims emitted by the action:

repository: santoshray02/csv-editor
repository_owner: santoshray02
workflow_ref: santoshray02/csv-editor/.github/workflows/publish.yml@refs/tags/v2.0.0
job_workflow_ref: santoshray02/csv-editor/.github/workflows/publish.yml@refs/tags/v2.0.0
ref: refs/tags/v2.0.0
environment: MISSING

The package also does not currently resolve on PyPI:

https://pypi.org/pypi/csv-editor/json -> 404

Root cause

The workflow has the required id-token: write permission, but PyPI does not appear to have a matching Trusted Publisher / pending publisher configured for this repository and workflow, or the configured publisher differs from the claims above.

PyPI’s troubleshooting docs say invalid-publisher means the OIDC token is valid but does not match any known publisher, usually due to a mismatch in repository owner, repository name, workflow filename, or environment.

Recommended fix

Configure a PyPI pending publisher / trusted publisher for:

  • PyPI project name: csv-editor
  • GitHub owner: santoshray02
  • GitHub repository: csv-editor
  • Workflow filename: publish.yml
  • Environment: either leave blank to match the current workflow, or preferably update the workflow to use a named environment like pypi and configure PyPI with pypi.

If TestPyPI publishing via workflow_dispatch should work too, configure a separate TestPyPI trusted publisher as well.

Suggested workflow hardening

It would be clearer to split the workflow into:

  1. A build job that uploads dist/* as an artifact.
  2. A publish-testpypi job for manual dispatch using environment testpypi.
  3. A publish-pypi job for GitHub releases using environment pypi.

That makes the PyPI trusted-publisher environment claim explicit instead of MISSING.

Related issue noticed

.github/workflows/publish-github.yml is named “Publish to GitHub Packages”, but it uploads to https://upload.pypi.org/legacy/. That is separate from the PyPI Trusted Publishing failure, but it likely explains why the GitHub Packages release workflow fails too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions