Skip to content

publish-to-test-pypi.yml also pushes to non-test PyPI #1935

Closed

Description

@soxofaan

from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing:

https://github.com/pypa/packaging.python.org/blob/bdda06fb4a1cf2ed277bdeab4c733f1e2371920c/source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst?plain=1#L90-L91

I find this a bit confusing while stepping though this guide:
it is suggested to create a workflow named publish-to-test-pypi.yml, but later it turns out that the workflow also pushes to the real (non-test) PyPI.

Wouldn't it be better to rename this file to just publish-to-pypi.yml?

Activity

  1. soxofaan commented on Oct 20, 2025

    @soxofaan
    ContributorAuthor

    Note that's a bit annoying if you find this out later and want to rename the workflow file, because you have to redo the whole "add trusted publisher" thing again (as it involves the workflow file name)

  2. nbehrnd commented on Nov 19, 2025

    @nbehrnd

    @soxofaan There is a separate issue on the same web site (at least about update by Nov 18, 2025; but probably present already for a couple of days) when it comes to section The whole CI/CD workflow and its workflow file: the conditional.

    To familiarize myself with CI/CD for an eventual publication to either of the two sites for my greet2org demo package, I assumed the line

    if: startsWith(github.ref, 'refs/tags/')
    

    to be safe to work with GitHub's environment. Well, on one hand there is the affirmative yes (if the project and yml file is known to test.pypi.org and the separate register of pypi.org). On the other hand, GitHub occasionally/systematically displays the two children which successfully run differently: one by the expected green check mark, the other as skipped:

    Image

    I'm not able to tell if this is (a perhaps temporary) issue with GitHub when viewing the repository with a web browser. For me, this was a source of confusion why git tag and git push --follow-tags didn't work the usual way. As it turned out, it probably wasn't an problem of git, and the manual increment of the version in pyproject.toml file and tag set likely wasn't necessary either. Maybe it is safer to omit if-conditionals in workflows to build and publish altogether, too.

  3. webknjaz commented on Nov 19, 2025

    @webknjaz
    Member

    I'm not able to tell if this is (a perhaps temporary) issue with GitHub when viewing the repository with a web browser.

    That's how conditional jobs are handled by GHA. Not a bug.

  4. webknjaz commented on Nov 19, 2025

    @webknjaz
    Member

    Maybe it is safer to omit if-conditionals in workflows to build and publish altogether, too.

    The idea is that if you figure out how to produce unique version strings, then you can publish to TestPyPI continuously. And "real" PyPI only gets uploads when actual release is triggered. Personally, I prefer workflow_dispatch instead of the tag shenanigans for many reasons but never refactored that example.

  5. soxofaan commented on Nov 19, 2025

    @soxofaan
    ContributorAuthor

    Thanks for responding, but as far as I understand this is off-topic w.r.t. what I want to highlight in this issue:

    • the suggested workflow file name contains "test-pypi": .github/workflows/publish-to-test-pypi.yml
    • but eventually, the workflow also covers pushing to the real PyPI
    • renaming the workflow file at that point is annoying because you have to re-do the "add trusted publisher" thing

    so I'd propose to update the user guide to suggest something like .github/workflows/publish-to-pypi.yml from the start

  6. webknjaz commented on Nov 20, 2025

    @webknjaz
    Member

    (looks like I started typing this yesterday but never clicked send 🤦)

    Note that's a bit annoying if you find this out later and want to rename the workflow file, because you have to redo the whole "add trusted publisher" thing again (as it involves the workflow file name)

    Fair. I don't know how it ended up being called like that. Likely my oversight.


    Feel free to send a PR with the name update. I also wanted to eventually improve it with more advanced examples but never got to it. So every small patch helps.

  7. webknjaz commented on Nov 20, 2025

    @webknjaz
    Member

    We could also make it a more generic publish-to-package-indices.yaml.

  8. nbehrnd commented on Nov 21, 2025

    @nbehrnd

    @webknjaz Thank you for your clarification it is GitHub's rules how to display things.

    Second, to me, your argument to use a separate fully automated workflow for the CD to test.pypi.org, and one requiring an additional intervention for pypi.org is convincing. Then, two separately maintained indices (and on the user's side, separate setup of trusted publishers and environments) equally is sensible, too. My issue thus is resolved.

  9. webknjaz commented on Nov 21, 2025

    @webknjaz
    Member

    You probably meant jobs, not workflows, right?

  10. nbehrnd commented on Nov 21, 2025

    @nbehrnd

    @webknjaz You are correct, my error; jobs. As in "jobs, which may consist of multiple steps like the checkout action" and "one, or multiple jobs may constitute a workflow".

  11. soxofaan commented on Nov 23, 2025

    @soxofaan
    ContributorAuthor

    -> created PR #1961

  12. webknjaz commented on Nov 23, 2025

    @webknjaz
    Member

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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