Skip to content

Automate build and release to PyPI #7390

Description

@hugovk

Currently the release process has many steps, including preparing things in this repo, and then starting a build in https://github.com/python-pillow/pillow-wheels, before downloading the sdist + wheel artifacts to disk, and manually uploading them to PyPI using twine.

I'd like us to move towards more automated releases, including using the new Trusted Publishers to upload wheels directly from the CI to PyPI, which is more secure:

We can do this in a phased manner, not all of these things would need to be done at once, to ensure we can still make releases with just some of them completed.

We could potentially deal with the Travis CI wheels later, and tackle GitHub Actions first as they're a bigger win and we don't know when Travis CI will go away.

Big picture:

  • Prepare release
  • Push a tag
  • The CI builds release artifacts
  • The CI uploads artifacts to PyPI

I'd suggest something along these lines:

  1. Move Linux and macOS https://github.com/python-pillow/pillow-wheels to this repo https://github.com/python-pillow/Pillow. We already have Windows wheels build here.

    • We'll need to add paths: / paths-ignore to workflows so we only trigger the main test workflows for "normal" code changes, and only trigger the wheel workflow for things like release and modifying its config
    • Upload wheels as GitHub artifacts in this repo instead
  2. Add automation to download artifacts and upload them to PyPI via Trusted Publishing

Thoughts?

Activity

  1. wiredfool commented on Sep 11, 2023

    @wiredfool
    Member

    This sounds like a great step.

  2. aclark4life commented on Sep 11, 2023

    @aclark4life
    Member

    Love it!!

  3. radarhere commented on Sep 24, 2023

    @radarhere
    Member

    I've created #7418 for 1.

  4. pinned this issue on Nov 12, 2023
  5. hugovk commented on Nov 12, 2023

    @hugovk
    MemberAuthor

    I've opened #7544 to create the sdist during the release build.


    Next, I'd like us to move the Windows wheel building from test-windows.yml into the same wheels.yml workflow.

    So we get something like this:

    image

    And the Windows wheels should be part of the same dist.zip artifact containing the Linux and macOS wheels, and the sdist.

    I think we also probably want to use a reusable workflow, similar to wheels-linux.yml and wheels-macos.yml.

    We don't need to build the wheels anymore in test-windows.yml. If there's a lot of common steps needed for testing (in test-windows.yml) and building wheels, a reusable workflow could be useful here.

    This doesn't all need to be done in one go, incremental steps are fine, as long as they're atomic changes and we're still able to make releases during any intermediate step.

    Any thoughts on how to approach this? cc @nulano


    After all this is done, we have all* the release files created in one place on the CI, and do the upload to PyPI! But one step at a time :)

    (* All the GHA files, not Travis CI, which will still need manual upload, but they should be ready before all the automation.)

  6. nulano commented on Nov 15, 2023

    @nulano
    Contributor

    I've managed to use cibuildwheel to build wheels locally, I should be able to make a PR on top of #7552 for Windows wheels once it is merged.
    Edit: I've got a WIP branch ready, including ARM64 wheels (although I have no way to test them!).
    Edit2: I've created PR #7580.

  7. hugovk commented on Nov 16, 2023

    @hugovk
    MemberAuthor

    Sounds good! When the time comes, we can ask around for someone to test the ARM64 wheels :)

  8. nulano commented on Nov 16, 2023

    @nulano
    Contributor

    I've since realized that I can borrow a relative's M2 MacBook to test the wheels.
    The Python 3.12 wheel from my WIP branch tested OK.
    I then used cibuildwheel manually in the terminal to build and test wheels for the 10.1.0 tag for #7547 (comment)

  9. radarhere commented on Dec 26, 2023

    @radarhere
    Member

    #7616 has now been merged.

    @aclark4life could you go to https://pypi.org/manage/project/pillow/settings/publishing/ and add a publisher?

    Owner: python-pillow
    Repository name: Pillow
    Workflow name: wheels.yml
    Environment name: release-pypi

  10. hugovk commented on Dec 27, 2023

    @hugovk
    MemberAuthor

    @aclark4life Please can you also set up an environment named release-pypi in this repo, that all the release managers can access: at least @radarhere and me, probably also you and @wiredfool for backup.

  11. aclark4life commented on Dec 27, 2023

    @aclark4life
    Member

    @radarhere @hugovk Thanks and done, I think! The env release-pypi already exists … need me to do anything to it?

    Screenshot 2023-12-27 at 9 52 12 AM

  12. hugovk commented on Dec 27, 2023

    @hugovk
    MemberAuthor

    Thanks, the publisher looks good!

    The env release-pypi already exists … need me to do anything to it?

    @aclark4life What settings does it have?

    @radarhere What settings should it have?

  13. aclark4life commented on Dec 27, 2023

    @aclark4life
    Member

    Most notably, no environment vars or secrets configured.

    Screenshot 2023-12-27 at 10 31 15 AM

  14. radarhere commented on Dec 27, 2023

    @radarhere
    Member

    The publisher looks good to me, thanks. The details I mentioned were the only ones I added.

  15. hugovk commented on Dec 27, 2023

    @hugovk
    MemberAuthor

    So when releasing, after pushing the tag, the CI will begin, build the sdist and all the wheels, and somehow put them in an environment? How does that look? What's the next step to upload to PyPI?

  16. aclark4life commented on Dec 27, 2023

    @aclark4life
    Member

    Probably need a testpypi release first.

  17. radarhere commented on Dec 28, 2023

    @radarhere
    Member

    When I was using Test PyPI in #7616, once sdist and the wheels were built, the action uploaded them, and that was it.

    https://github.com/radarhere/Pillow/actions/runs/7329629479/job/19960359962#step:4:1008

    View at:
    https://test.pypi.org/project/pillow/10.2.0.dev1/

    I presume that Test PyPI works the same way as real PyPI. I would have imagined that real PyPI releases don't rely on test PyPI to go first, since we've been ignoring test PyPI for every previous release we've done.

  18. hugovk commented on Dec 29, 2023

    @hugovk
    MemberAuthor

    Okay, so the environment isn't doing anything. Anyway, I'm excited for the next release!

    @radarhere Please will you update https://github.com/python-pillow/Pillow/blob/main/RELEASING.md? It can wait until after doing the release if you like.

  19. radarhere commented on Dec 29, 2023

    @radarhere
    Member

    Sure. I've created #7652

  20. radarhere commented on Jan 2, 2024

    @radarhere
    Member

    The tagged "Upload release to PyPI" ran smoothly in the Pillow 10.2.0 release.

    With that, is this completed?

  21. hugovk commented on Jan 2, 2024

    @hugovk
    MemberAuthor

    Great to hear it went smoothly!

    Before closing this issue, we still have Travis to automate. Shall we try my suggestion at #7485 (comment) to upload to PyPI directly from Travis?

  22. radarhere commented on Jan 2, 2024

    @radarhere
    Member

    Sure, sounds good if it works.

  23. hugovk commented on Jan 3, 2024

    @hugovk
    MemberAuthor

    Plan C: please see PR #7690 to replace Travis native builds with GHA emulated builds.

  24. aclark4life commented on Jan 3, 2024

    @aclark4life
    Member

    Only loosely following, but I think I like Plan C!! Thanks all ❤️ (Losing travis in exchange for longer build times is my "hot take", sounds worth it to me.)

  25. unpinned this issue on Jan 4, 2024
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions