Cache-friendly uvx in GitHub Actions with UV_EXCLUDE_NEWER
Setting UV_EXCLUDE_NEWER to a fixed date and using it in the GitHub Actions cache key makes uvx tool-name resolve to a pinned, reproducible version that caches reliably.
What it is
A tip for using the `uvx` command from Astral's uv Python tool inside GitHub Actions workflows.
What it does
Sets a `UV_EXCLUDE_NEWER` environment variable, such as `"2026-07-12"`, at the start of a workflow and includes that value in the GitHub Actions cache key, so `uvx tool-name` always resolves to the most recent version as of that date instead of silently re-resolving to whatever is newest on every run.
Why it matters
Unlike a plain `uvx tool-name` invocation, which can pick a different version each run and bust caches unpredictably, this recipe makes CI runs reproducible and lets the dependency resolution actually benefit from caching.
How to use it
In a GitHub Actions workflow, set `UV_EXCLUDE_NEWER: "YYYY-MM-DD"` as an env var, then include that same value as part of the cache key used for the uv/uvx cache step.