mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-02-23 17:15:20 +08:00
Add input python-version (#174)
This commit is contained in:
parent
420915557e
commit
ee4fa33003
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
- name: Make sure no changes from linters are detected
|
- name: Make sure no changes from linters are detected
|
||||||
run: |
|
run: |
|
||||||
git diff --exit-code
|
git diff --exit-code
|
||||||
test-latest-version:
|
test-default-version:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
14
README.md
14
README.md
@ -14,6 +14,7 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
|||||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||||
- [Install a specific version](#install-a-specific-version)
|
- [Install a specific version](#install-a-specific-version)
|
||||||
- [Install a version by supplying a semver range](#install-a-version-by-supplying-a-semver-range)
|
- [Install a version by supplying a semver range](#install-a-version-by-supplying-a-semver-range)
|
||||||
|
- [Python version](#python-version)
|
||||||
- [Validate checksum](#validate-checksum)
|
- [Validate checksum](#validate-checksum)
|
||||||
- [Enable Caching](#enable-caching)
|
- [Enable Caching](#enable-caching)
|
||||||
- [Cache dependency glob](#cache-dependency-glob)
|
- [Cache dependency glob](#cache-dependency-glob)
|
||||||
@ -75,6 +76,19 @@ to install the latest version that satisfies the range.
|
|||||||
version: "0.4.x"
|
version: "0.4.x"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Python version
|
||||||
|
|
||||||
|
You can use the input `python-version` to set the environment variable `UV_PYTHON` for the rest
|
||||||
|
of your workflow.
|
||||||
|
This will override any python version specifications in `pyproject.toml` and `.python-version`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Install the latest version of uv and set the python version to 3.12
|
||||||
|
uses: astral-sh/setup-uv@v3
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
```
|
||||||
|
|
||||||
### Validate checksum
|
### Validate checksum
|
||||||
|
|
||||||
You can specify a checksum to validate the downloaded executable. Checksums up to the default version
|
You can specify a checksum to validate the downloaded executable. Checksums up to the default version
|
||||||
|
@ -6,6 +6,9 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: "The version of uv to install"
|
description: "The version of uv to install"
|
||||||
default: "latest"
|
default: "latest"
|
||||||
|
python-version:
|
||||||
|
description: "The version of Python to set UV_PYTHON to"
|
||||||
|
required: false
|
||||||
checksum:
|
checksum:
|
||||||
description: "The checksum of the uv version to install"
|
description: "The checksum of the uv version to install"
|
||||||
required: false
|
required: false
|
||||||
|
3
dist/save-cache/index.js
generated
vendored
3
dist/save-cache/index.js
generated
vendored
@ -82614,10 +82614,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.githubToken = exports.toolDir = exports.toolBinDir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
exports.githubToken = exports.toolDir = exports.toolBinDir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.pythonVersion = exports.version = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
||||||
exports.version = core.getInput("version");
|
exports.version = core.getInput("version");
|
||||||
|
exports.pythonVersion = core.getInput("python-version");
|
||||||
exports.checkSum = core.getInput("checksum");
|
exports.checkSum = core.getInput("checksum");
|
||||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||||
|
14
dist/setup/index.js
generated
vendored
14
dist/setup/index.js
generated
vendored
@ -90028,10 +90028,11 @@ function run() {
|
|||||||
addUvToPath(setupResult.uvDir);
|
addUvToPath(setupResult.uvDir);
|
||||||
addToolBinToPath();
|
addToolBinToPath();
|
||||||
setToolDir();
|
setToolDir();
|
||||||
core.setOutput("uv-version", setupResult.version);
|
setupPython();
|
||||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
|
||||||
addMatchers();
|
addMatchers();
|
||||||
setCacheDir(inputs_1.cacheLocalPath);
|
setCacheDir(inputs_1.cacheLocalPath);
|
||||||
|
core.setOutput("uv-version", setupResult.version);
|
||||||
|
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||||
if (inputs_1.enableCache) {
|
if (inputs_1.enableCache) {
|
||||||
yield (0, restore_cache_1.restoreCache)(setupResult.version);
|
yield (0, restore_cache_1.restoreCache)(setupResult.version);
|
||||||
}
|
}
|
||||||
@ -90099,6 +90100,12 @@ function setToolDir() {
|
|||||||
core.info(`Set UV_TOOL_DIR to ${inputs_1.toolDir}`);
|
core.info(`Set UV_TOOL_DIR to ${inputs_1.toolDir}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function setupPython() {
|
||||||
|
if (inputs_1.pythonVersion !== "") {
|
||||||
|
core.exportVariable("UV_PYTHON", inputs_1.pythonVersion);
|
||||||
|
core.info(`Set UV_PYTHON to ${inputs_1.pythonVersion}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
function setCacheDir(cacheLocalPath) {
|
function setCacheDir(cacheLocalPath) {
|
||||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||||
@ -90158,10 +90165,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.githubToken = exports.toolDir = exports.toolBinDir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.version = void 0;
|
exports.githubToken = exports.toolDir = exports.toolBinDir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.pythonVersion = exports.version = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
||||||
exports.version = core.getInput("version");
|
exports.version = core.getInput("version");
|
||||||
|
exports.pythonVersion = core.getInput("python-version");
|
||||||
exports.checkSum = core.getInput("checksum");
|
exports.checkSum = core.getInput("checksum");
|
||||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
checkSum,
|
checkSum,
|
||||||
enableCache,
|
enableCache,
|
||||||
githubToken,
|
githubToken,
|
||||||
|
pythonVersion,
|
||||||
toolBinDir,
|
toolBinDir,
|
||||||
toolDir,
|
toolDir,
|
||||||
version,
|
version,
|
||||||
@ -45,12 +46,13 @@ async function run(): Promise<void> {
|
|||||||
addUvToPath(setupResult.uvDir);
|
addUvToPath(setupResult.uvDir);
|
||||||
addToolBinToPath();
|
addToolBinToPath();
|
||||||
setToolDir();
|
setToolDir();
|
||||||
core.setOutput("uv-version", setupResult.version);
|
setupPython();
|
||||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
|
||||||
|
|
||||||
addMatchers();
|
addMatchers();
|
||||||
setCacheDir(cacheLocalPath);
|
setCacheDir(cacheLocalPath);
|
||||||
|
|
||||||
|
core.setOutput("uv-version", setupResult.version);
|
||||||
|
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||||
|
|
||||||
if (enableCache) {
|
if (enableCache) {
|
||||||
await restoreCache(setupResult.version);
|
await restoreCache(setupResult.version);
|
||||||
}
|
}
|
||||||
@ -133,6 +135,13 @@ function setToolDir(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupPython(): void {
|
||||||
|
if (pythonVersion !== "") {
|
||||||
|
core.exportVariable("UV_PYTHON", pythonVersion);
|
||||||
|
core.info(`Set UV_PYTHON to ${pythonVersion}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setCacheDir(cacheLocalPath: string): void {
|
function setCacheDir(cacheLocalPath: string): void {
|
||||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||||
|
@ -2,6 +2,7 @@ import * as core from "@actions/core";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
export const version = core.getInput("version");
|
export const version = core.getInput("version");
|
||||||
|
export const pythonVersion = core.getInput("python-version");
|
||||||
export const checkSum = core.getInput("checksum");
|
export const checkSum = core.getInput("checksum");
|
||||||
export const enableCache = core.getInput("enable-cache") === "true";
|
export const enableCache = core.getInput("enable-cache") === "true";
|
||||||
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user