Using uvx in GitHub Actions in a cache-friendly way

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

CI workflows can stop re-downloading Python tools from PyPI on every run by pinning a date in the UV_EXCLUDE_NEWER variable and baking it into the cache key.

Read this as

Simon Willison published a recipe for running Python tools inside GitHub Actions, the automation system that runs code when software projects change. Normally each run downloads the tool again from PyPI, the public Python package store. His trick sets a variable called UV_EXCLUDE_NEWER to a fixed date, so every run uses the version of the tool that existed on that date, and reuses it from GitHub's cache. Upgrading tools later means manually bumping the date.

Teams running Python tooling in GitHub Actions typically pay, in time and network load, for repeated PyPI downloads on every workflow run. Willison's recipe fixes this by fixing a resolution date (he used 2026-07-12) via the UV_EXCLUDE_NEWER environment variable and including it in the cache key, so runs reuse cached tools until someone bumps the date. The trade-off is manual cache-busting on upgrades.

Willison's recipe sets UV_EXCLUDE_NEWER="2026-07-12" as an environment variable at workflow start and uses the value in the GitHub Actions cache key. uvx then resolves tool versions as of that date on the first run and subsequent runs hit the Actions cache instead of PyPI. Upgrades require manually bumping the date. He also links an open issue on astral-sh/setup-uv requesting caching by default rather than purging wheels.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

uvx GitHub Actions UV_EXCLUDE_NEWER PyPI setup-uv Datasette

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading