Skip to content

Isolate package build and publish#137

Merged
StanFromIreland merged 10 commits intopython:masterfrom
hugovk:isolate-publish
Apr 28, 2026
Merged

Isolate package build and publish#137
StanFromIreland merged 10 commits intopython:masterfrom
hugovk:isolate-publish

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Apr 24, 2026

This follows the https://github.com/python/blurb/blob/main/.github/workflows/release.yml pattern as much as possible, which is very similar to the other PyPI Trusted Publishing workflows we have under https://github.com/python/, which will help ease maintenance burden.

As before, it publishes to Test PyPI for commits to main, and to prod PyPI when releases are created.

The main difference is we build the artifacts (sdist and wheel) in an isolated job then upload as GH artifacts. Then another isolated job will download and publish to the relevant index.

This isolates the installation of build deps from the job that uploads, and helps prevent supply chain attacks.

It will also run when we're not in "publish mode", and verify the artifacts can be built. We also get a nice summary of the packages and their contents. For example:

This also includes extra linting of artifacts. There was a bunch of "W002: Wheel contains duplicate files" warnings:

I've ignored these, as I think these are inherent to how tzdata is built? Anyway, this is pre-existing in the last published wheel: check-wheel-contents --no-config tzdata-2026.2-py2.py3-none-any.whl

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
# This workflow is triggered two ways:
#
# 1. When a tag is created, the workflow will upload the package to
# 1. When a commit is made, the workflow will upload the package to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, I won't be able to do releases in one PR now, right? It'll require me to do two.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Please could you explain your current release process?

https://github.com/python/tzdata/blob/master/docs/maintaining.rst#making-a-release doesn't mention PRs.

That says:

  • Push a tag -> publishes to Test PyPI.
  • Create a GH release -> publishes to PyPI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Push a tag -> publishes to Test PyPI.

I can push a tag for a commit in a PR, as long as it's from a branch in this repository (which is what the bot does).

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated

- uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0

# Publish to Test PyPI on every commit on main.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't this fail due to duplicate version numbers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. As mentioned, blurb uses hatch-vcs so dev versions are like 2.0.1.dev37 and will change based on the number of commits since the last tag. So it's not a problem there.

Will have to rethink this!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think changing the if: guard to pushed tags would work?

Then we can still test the package build works when not publishing. And only publish for tags (Test PyPI) and releases (prod PyPI).

@hugovk hugovk marked this pull request as draft April 25, 2026 15:41
hugovk added 2 commits April 25, 2026 18:41
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 28, 2026

Okay, how's it look now?

@hugovk hugovk marked this pull request as ready for review April 28, 2026 16:20
@StanFromIreland
Copy link
Copy Markdown
Member

Is it possible to also verify that all the tests have passed before uploading?

@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 28, 2026

Yes, we could change:

image

To add a test gate in the middle:

image

But tests already run on every PR and every merge to master, so usually the precondition is that the CI is green before you even start a release.

But can add it if you like?

@StanFromIreland
Copy link
Copy Markdown
Member

But tests already run on every PR and every merge to master, so usually the precondition is that the CI is green before you even start a release.

Yes, but currently I've manually been checking before making the release, which I don't like (or maybe I'm just too misanthropic ;-). If it is a terrible pain to do I can merge this as-is.

@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 28, 2026

Sure, I wouldn't bother for a repo I'm maintaining, but I'm not maintaining this one :)

How's this?

Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

Last few nits, thanks Hugo!

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread pyproject.toml
hugovk and others added 2 commits April 28, 2026 21:44
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

Thanks Hugo!

@StanFromIreland StanFromIreland merged commit 68d4d51 into python:master Apr 28, 2026
33 checks passed
@hugovk hugovk deleted the isolate-publish branch April 28, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants