Skip to content

Conversation

EvMossan
Copy link
Contributor

@EvMossan EvMossan commented Jun 27, 2025

Summary

This PR enables Trusted Publishing (OIDC) uploads to PyPI when a GitHub release is published.

What’s changed

  • .github/workflows/wheels.yml

    • adds a new publish job that
      1. downloads all wheel / sdist artifacts from upstream jobs;
      2. excludes Pyodide wheels (*pyodide*.whl);
      3. runs pypa/gh-action-pypi-publish@v1 in the pypi environment.
  • doc/source/whatsnew/v3.0.0.rst

    • adds a single Build / CI line announcing the switch to Trusted Publishing
  • doc/source/development/maintaining.rst

    • drop manual twine step and note Trusted Publishing

No other files or CI matrix settings were changed.

Release prerequisites

  • GitHub repo must have an environment named pypi (OIDC token permission enabled).
  • The pandas project on PyPI must list pandas-dev/pandas → “pypi” as a Trusted Publisher (see https://docs.pypi.org/trusted-publishers/).

@EvMossan EvMossan requested a review from mroeschke as a code owner June 27, 2025 08:03
@EvMossan
Copy link
Contributor Author

EvMossan commented Jun 27, 2025

CI failed in the docstring-validation step with

AttributeError: 'getset_descriptor' object has no attribute '__module__'. Did you mean: '__reduce__'?

This occurs before my code runs, so it isn’t caused by the changes in this PR.
It looks related to the latest numpydoc release.
I’ll re-run CI once the upstream fix lands.

@EvMossan EvMossan closed this Jun 28, 2025
@EvMossan EvMossan reopened this Jun 28, 2025
@EvMossan
Copy link
Contributor Author

EvMossan commented Jul 1, 2025

All comments addressed and conversations resolved - ready for another look. Thanks!

@EvMossan EvMossan closed this Jul 8, 2025
@EvMossan EvMossan reopened this Jul 8, 2025
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EvMossan thanks a lot for working on this! (and @EpicWink for the review)

@mroeschke I updated the PyPI configuration to enable trusted publishing on that side.

I suppose we can only test this really once doing a next pre-release?
Could we already test the first part of the added job by temporarily commenting out the last pypa/gh-action-pypi-publish step, but so at least we can check the downloading and filtering of the artifacts is working?

Comment on lines +16 to +17
release:
types: [published]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EpicWink you suggested to add this, but I am wondering if that is needed? As I understand, this wheels.yml workflow will run on the commit pushed to main with a tag, and so that way it will already run for a release? And we can then upload the wheels from that run?

Copy link
Contributor

@EpicWink EpicWink Jul 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A GitHub release publish happens after a push, allowing you to review the CI, and write release notes in the GitHub release, before triggering the publish to PyPI. Up to you how you want the release workflow to be, if you want to publish unconditionally.

An alternative is to split the workflow into two files (and therefore two workflows), where the publish job downloads the artefacts from the build job of the other workflow, and the publish workflow is triggered from the build workflow's completion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EpicWink thanks for the explanation, got it! Since we still manually create the github release (not automated from CI when alls builds passed), it indeed seems fine to only run the PyPI publish step afterwards.

- name: Publish to **PyPI** (Trusted Publishing)
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line needed? (it's not included in the example in https://docs.pypi.org/trusted-publishers/using-a-publisher/)

Copy link
Contributor

@EpicWink EpicWink Jul 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, and as far as I know there's no recommendation to hard-code it. When the upload API 2.0 PEP lands, this URL and action will change anyway.

@jorisvandenbossche jorisvandenbossche added this to the 3.0 milestone Jul 19, 2025
@EpicWink
Copy link
Contributor

EpicWink commented Jul 19, 2025

I suppose we can only test this really once doing a next pre-release?

Yes, fortunately PyPI (production) supports uploading pre-releases.

Could we already test the first part of the added job by temporarily commenting out the last pypa/gh-action-pypi-publish step, but so at least we can check the downloading and filtering of the artifacts is working?

That could work, as long as it's in a protected tag, but you would be creating a tag just to test this, unless you change the workflow definition further to support a non-version-tag ref.

Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's give this a try. Thanks @EvMossan and @EpicWink!

@jorisvandenbossche jorisvandenbossche merged commit e817930 into pandas-dev:main Sep 21, 2025
93 of 94 checks passed
jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this pull request Sep 21, 2025
@EvMossan
Copy link
Contributor Author

Thank you!

mroeschke pushed a commit that referenced this pull request Sep 22, 2025
…els workflow (#61669) (#61718) (#62395)

Co-authored-by: Evgenii Mosikhin <[email protected]>
Co-authored-by: Evgenii Mosikhin <[email protected]>
Co-authored-by: Laurie O <[email protected]>
jzwick pushed a commit to jzwick/pandas that referenced this pull request Oct 1, 2025
@jorisvandenbossche
Copy link
Member

FWIW, I have tested the workflow when releasing 2.3.3, and we still have some issue to resolve. Essentially the problem was that on the "release" event, we didn't actually run the jobs to build the sdist and wheels (their if does not include a check for release), and so then the publish step also did not run because this has needs: on the sdist/wheel build ..

This should be easy to solve by updating the if: clauses.
Longer term, I think it would still be nice to avoid rebuilding the wheels for the release event, but reusing the ones that were build (if successfully) from pushing the tag (#61718 (comment))

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

Labels

Build Library building on various platforms CI Continuous Integration Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Switch to trusted publishing for package upload to PyPI in CI

5 participants