Add input python-version (#174)

This commit is contained in:
Kevin Stillhammer 2024-11-28 21:41:37 +01:00 committed by GitHub
parent 420915557e
commit ee4fa33003
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 44 additions and 8 deletions

View File

@ -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:

View File

@ -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

View File

@ -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
View File

@ -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
View File

@ -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") || "";

View File

@ -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}`);

View File

@ -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") || "";