Skip to content

Comments

feat(ci): switch to uv publish for PyPI uploads#13991

Open
woodruffw wants to merge 3 commits intopyca:mainfrom
woodruffw-forks:ww/uv-publish
Open

feat(ci): switch to uv publish for PyPI uploads#13991
woodruffw wants to merge 3 commits intopyca:mainfrom
woodruffw-forks:ww/uv-publish

Conversation

@woodruffw
Copy link
Contributor

This switches pypi-publish.yml from gh-action-pypi-publish to uv publish. The upload itself is still through Trusted Publishing, and attestations are preserved through astral-sh/attest-action (which can be removed in the medium-term, once uv publish itself supports attestation generation).

Noting a few things from conversation with @reaperhulk:

  • This runs uv publish directly, since the uv binary is configured on the $PATH implicitly via astral-sh/attest-action. This is arguably undesirable, since cryptography otherwise pins uv via a requirements file.
  • Separately, this currently runs the latest uv release at all times, since astral-sh/attest-action doesn't attempt to pin it (besides a lower bound for compatibility). This is "ok" from Astral's own trust domain, but it might not be what you want in your release pathway for stability/reproducibility purposes.

TL;DR: This all works, but the current approach may not be what you want in terms of version pinning.

@woodruffw
Copy link
Contributor Author

(My plan here is to make attest-action hard-pin the uv version, and then release a new version that I'll bump to in this PR.)

attestations: ${{ env.PYPI_URL == 'https://upload.pypi.org/legacy/' }}
# uv is present because attest-action installs it.
run: |
uv publish --trusted-publishing=always dist/*
Copy link
Member

Choose a reason for hiding this comment

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

Is uv in the base image? If not, it's not installed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's installed implicitly via attest-action, since workspace tools are global state. I find this kind of spooky/scary though.

Copy link
Member

Choose a reason for hiding this comment

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

please add a comment at least

Copy link
Member

Choose a reason for hiding this comment

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

Oh I just realized this won't work, since attest-action only runs conditionally on it being a push to prod pypi.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is still an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, was going to fix it today. Sorry for the re-ping from the new activity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've added a setup-uv to ensure uv is always present. This feels kind of wrong given that you use python -m pip install -c ci-constraints-requirements.txt 'uv' elsewhere, but the alternative would be to increase the size of the publish job here significantly (with a checkout + setup-python).

Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Comment on lines +46 to +48
- uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
with:
save-cache: false
Copy link
Member

Choose a reason for hiding this comment

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

Does this also hash pin the version of uv that's installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, although it's a floating resolution (the action knows all of the hashes, and selects the latest version). That doesn't seem ideal though, and it's an additional failure point with GitHub's unreliability. I'm going to switch it to the same constraint approach you use elsewhere 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we want everything pinned to a particular version. Only way to avoid shit breaking when we need it to work.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants