更新于 2026/07/14 00:56
uvx 在 GitHub Actions 中实现缓存友好的工具调用
Simon Willison 分享了一个在 GitHub Actions 中使用 uvx 工具时实现缓存友好的方案。核心思路是在 workflow 中设置 UV_EXCLUDE_NEWER 环境变量固定日期,并将该日期作为缓存 key 的一部分。
这样每次运行 uvx tool-name 时都会解析为该日期的最新版本,通过手动更新日期即可升级工具并刷新缓存。避免了每次 workflow 运行都从 PyPI 重新下载工具及其依赖,显著减少 CI 耗时。
该技巧对频繁使用 Python 工具的 CI 流水线有实际工程价值,尤其适合需要稳定工具版本、又希望按需升级的场景。
速读
用 UV_EXCLUDE_NEWER 固定日期作为缓存 key,避免每次 CI 都从 PyPI 下载工具
相关源 (1)
- Simon Willison · 2026/7/14 00:56:20https://simonwillison.net/2026/Jul/14/uvx-github-actions-cache/#atom-everything