gh-action-pypi-publish: `invalid-publisher` error when using reusable workflow

My publish step sits in a resuable workflow .github/workflows/pytest-release.yml.

When setting up trusted publishing, should the workflow name be the file in the actual repo (test.yml in my case) or the reusable workflow file being exectued (pytest-release.yml)? The docs sound like the former which throws

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

  • invalid-publisher: valid token, but no corresponding publisher

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 8
  • Comments: 29 (20 by maintainers)

Commits related to this issue

Most upvoted comments

would you accept a bounty for this feature? happy to use GH Sponsors

This is a very thoughtful offer, thank you! Unfortunately, I can’t really personally take bounties for this kind of work – OSS engineering is my full time job, and I get paid a salary for it. I might do this eventually as a side project, but to do it professionally I’ll need one of my clients (or a new client) to fund it.

(I am happy to discuss that further if you’d like, but I also completely understand if that kind of funding isn’t what you’re interested in.)

Also, some people managed to get it to work when the reusable workflow is within the same repo and all the secrets are inherited, it seems. I don’t want to break them.

@webknjaz you mentioned some folks were able to successfully setup trusted publishers when using reusable workflows from the same repository. I’m trying to do the same, but running into errors even when inheriting secrets. Do you have any examples of a successful configuration here?

For reference my top level workflow is, https://github.com/LLNL/repligit/blob/main/.github/workflows/ci.yml

Which is calling this reusable workflow after unit-tests have all passed, https://github.com/LLNL/repligit/blob/main/.github/workflows/publish.yml

And I’ve set both as trusted publishers on PyPI for the project.

Makes sense! I’ll try and set aside some time to add that warning.

@woodruffw maybe not fail hard but show a big explainer for this specific case? I don’t remember if workflow_call is exposed as an event. I think it’s the event of the calling workflow that is visible to us. Also, some people managed to get it to work when the reusable workflow is within the same repo and all the secrets are inherited, it seems. I don’t want to break them. But if the upload fails, showing something that is impossible to miss would be a good idea. For some reason I thought we already had that warning in the error messages calling out the reusable workflows special case explicitly but it seems like it’s not there.

To add to what @webknjaz said: the limitations with reusable workflows are currently documented here: https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github

Adding support for reusable workflows is on my list of things to do, but there’s no current timeline for it.

@mikegerber v1.8.9 has more debug info

Could gh-action-pypi-publish give more debugging info - if possible? Eg. the values of Publisher - Repository - Workflow - Environment name that should be used in the Trusted publisher configuration?

I stumbled upon this, and having the reusable workflow in the same repo also causes this error, it seems.