mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-12-15 11:07:14 +00:00
Compare commits
3 Commits
7dd56c18e9
...
windows-to
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2233977af9 | ||
|
|
363497d0ae | ||
|
|
561bff6f70 |
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@@ -105,3 +105,14 @@ jobs:
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
- run: uvx ruff --version
|
||||
test-tool-install:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
- run: uv tool install ruff
|
||||
- run: ruff --version
|
||||
|
||||
20
README.md
20
README.md
@@ -13,11 +13,13 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
||||
- [Usage](#usage)
|
||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||
- [Install a specific version](#install-a-specific-version)
|
||||
- [Install a version by supplying a semver range](#install-a-version-by-supplying-a-semver-range)
|
||||
- [Validate checksum](#validate-checksum)
|
||||
- [Enable Caching](#enable-caching)
|
||||
- [Cache dependency glob](#cache-dependency-glob)
|
||||
- [Local cache path](#local-cache-path)
|
||||
- [GitHub authentication token](#github-authentication-token)
|
||||
- [UV_TOOL_BIN_DIR](#uv_tool_bin_dir)
|
||||
- [How it works](#how-it-works)
|
||||
- [FAQ](#faq)
|
||||
|
||||
@@ -178,6 +180,24 @@ are not sufficient, you can provide a custom GitHub token with the necessary per
|
||||
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### UV_TOOL_BIN_DIR
|
||||
|
||||
On Windows `UV_TOOL_BIN_DIR` is set to the `TMP` dir. On GitHub hosted runners this is on the much
|
||||
faster `D:` drive. This path is also automatically added to the PATH.
|
||||
|
||||
On all other platforms the tool binaries get installed to the
|
||||
[default location](https://docs.astral.sh/uv/concepts/tools/#the-bin-directory).
|
||||
|
||||
If you want to change this behaviour (especially on self-hosted runners) you can use the
|
||||
`tool-bin-dir` input:
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv with a custom tool bin dir
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
tool-bin-dir: "/path/to/tool/bin"
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
This action downloads uv from the uv repo's official
|
||||
|
||||
@@ -29,6 +29,9 @@ inputs:
|
||||
cache-local-path:
|
||||
description: "Local path to store the cache."
|
||||
default: ""
|
||||
tool-bin-dir:
|
||||
description: "Custom path to set UV_TOOL_BIN_DIR to."
|
||||
required: false
|
||||
outputs:
|
||||
uv-version:
|
||||
description: "The installed uv version. Useful when using latest."
|
||||
|
||||
15
dist/save-cache/index.js
generated
vendored
15
dist/save-cache/index.js
generated
vendored
@@ -83008,7 +83008,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.cacheDependencyGlob = exports.githubToken = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
||||
exports.githubToken = exports.toolBinDir = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
exports.version = core.getInput("version");
|
||||
@@ -83016,8 +83016,19 @@ exports.checkSum = core.getInput("checksum");
|
||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
exports.cacheLocalPath = getCacheLocalPath();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
exports.cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
exports.toolBinDir = getToolBinDir();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
function getToolBinDir() {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
return toolBinDirInput;
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
return "D:\\a\\_temp\\uv-tool-bin-dir";
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getCacheLocalPath() {
|
||||
const cacheLocalPathInput = core.getInput("cache-local-path");
|
||||
if (cacheLocalPathInput !== "") {
|
||||
|
||||
27
dist/setup/index.js
generated
vendored
27
dist/setup/index.js
generated
vendored
@@ -89835,8 +89835,7 @@ function downloadLatest(platform, arch, checkSum, githubToken) {
|
||||
}
|
||||
const version = yield getVersion(uvExecutablePath);
|
||||
yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version);
|
||||
const cachedToolDir = yield tc.cacheDir(uvDir, constants_1.TOOL_CACHE_NAME, version, arch);
|
||||
return { cachedToolDir, version };
|
||||
return { cachedToolDir: uvDir, version };
|
||||
});
|
||||
}
|
||||
function getVersion(uvExecutablePath) {
|
||||
@@ -90033,6 +90032,7 @@ function run() {
|
||||
}
|
||||
const setupResult = yield setupUv(platform, arch, inputs_1.version, inputs_1.checkSum, inputs_1.githubToken);
|
||||
addUvToPath(setupResult.uvDir);
|
||||
addToolBinToPath();
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
addMatchers();
|
||||
@@ -90076,6 +90076,14 @@ function addUvToPath(cachedPath) {
|
||||
core.addPath(cachedPath);
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
function addToolBinToPath() {
|
||||
if (inputs_1.toolBinDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_BIN_DIR", inputs_1.toolBinDir);
|
||||
core.info(`Set UV_TOOL_BIN_DIR to ${inputs_1.toolBinDir}`);
|
||||
core.addPath(inputs_1.toolBinDir);
|
||||
core.info(`Added ${inputs_1.toolBinDir} to the path`);
|
||||
}
|
||||
}
|
||||
function setCacheDir(cacheLocalPath) {
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
@@ -90135,7 +90143,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.cacheDependencyGlob = exports.githubToken = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
||||
exports.githubToken = exports.toolBinDir = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
exports.version = core.getInput("version");
|
||||
@@ -90143,8 +90151,19 @@ exports.checkSum = core.getInput("checksum");
|
||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
exports.cacheLocalPath = getCacheLocalPath();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
exports.cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
exports.toolBinDir = getToolBinDir();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
function getToolBinDir() {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
return toolBinDirInput;
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
return "D:\\a\\_temp\\uv-tool-bin-dir";
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getCacheLocalPath() {
|
||||
const cacheLocalPathInput = core.getInput("cache-local-path");
|
||||
if (cacheLocalPathInput !== "") {
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as exec from "@actions/exec";
|
||||
import * as path from "path";
|
||||
import { Architecture, Platform } from "../utils/platforms";
|
||||
import { validateChecksum } from "./checksum/checksum";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
|
||||
import { OWNER, REPO } from "../utils/constants";
|
||||
|
||||
export async function downloadLatest(
|
||||
platform: Platform,
|
||||
@@ -39,14 +39,8 @@ export async function downloadLatest(
|
||||
}
|
||||
const version = await getVersion(uvExecutablePath);
|
||||
await validateChecksum(checkSum, downloadPath, arch, platform, version);
|
||||
const cachedToolDir = await tc.cacheDir(
|
||||
uvDir,
|
||||
TOOL_CACHE_NAME,
|
||||
version,
|
||||
arch,
|
||||
);
|
||||
|
||||
return { cachedToolDir, version };
|
||||
return { cachedToolDir: uvDir, version };
|
||||
}
|
||||
|
||||
async function getVersion(uvExecutablePath: string): Promise<string> {
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
checkSum,
|
||||
enableCache,
|
||||
githubToken,
|
||||
toolBinDir,
|
||||
version,
|
||||
} from "./utils/inputs";
|
||||
|
||||
@@ -41,6 +42,7 @@ async function run(): Promise<void> {
|
||||
);
|
||||
|
||||
addUvToPath(setupResult.uvDir);
|
||||
addToolBinToPath();
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
|
||||
@@ -102,6 +104,15 @@ function addUvToPath(cachedPath: string): void {
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
|
||||
function addToolBinToPath(): void {
|
||||
if (toolBinDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_BIN_DIR", toolBinDir);
|
||||
core.info(`Set UV_TOOL_BIN_DIR to ${toolBinDir}`);
|
||||
core.addPath(toolBinDir);
|
||||
core.info(`Added ${toolBinDir} to the path`);
|
||||
}
|
||||
}
|
||||
|
||||
function setCacheDir(cacheLocalPath: string): void {
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
|
||||
@@ -6,8 +6,20 @@ export const checkSum = core.getInput("checksum");
|
||||
export const enableCache = core.getInput("enable-cache") === "true";
|
||||
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
export const cacheLocalPath = getCacheLocalPath();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
export const toolBinDir = getToolBinDir();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
||||
function getToolBinDir(): string | undefined {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
return toolBinDirInput;
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
return "D:\\a\\_temp\\uv-tool-bin-dir";
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getCacheLocalPath(): string {
|
||||
const cacheLocalPathInput = core.getInput("cache-local-path");
|
||||
|
||||
Reference in New Issue
Block a user