Skip to content

Isolate package build and publish#137

Open
hugovk wants to merge 3 commits intopython:masterfrom
hugovk:isolate-publish
Open

Isolate package build and publish#137
hugovk wants to merge 3 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


jobs:
deploy:
# Always build & lint package.
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.

This comment is redundant, it is covered by the name.

# 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.

with:
repository-url: https://test.pypi.org/legacy/

# Publish to PyPI on GitHub Releases.
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.

Similarly redundant with the name and comment.

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
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.

Why? Does it need the entire history?


- 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?

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