mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-01-31 22:41:27 +08:00
Cache correct dir
This commit is contained in:
parent
eb355a21cb
commit
fd3ca5dc10
30
dist/setup/index.js
generated
vendored
30
dist/setup/index.js
generated
vendored
@ -85400,8 +85400,8 @@ const checksum_1 = __nccwpck_require__(4622);
|
|||||||
const utils_1 = __nccwpck_require__(239);
|
const utils_1 = __nccwpck_require__(239);
|
||||||
function downloadLatest(platform, arch, checkSum, githubToken) {
|
function downloadLatest(platform, arch, checkSum, githubToken) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const binary = `uv-${arch}-${platform}`;
|
const artifact = `uv-${arch}-${platform}`;
|
||||||
let downloadUrl = `https://github.com/${utils_1.OWNER}/${utils_1.REPO}/releases/latest/download/${binary}`;
|
let downloadUrl = `https://github.com/${utils_1.OWNER}/${utils_1.REPO}/releases/latest/download/${artifact}`;
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
downloadUrl += '.zip';
|
downloadUrl += '.zip';
|
||||||
}
|
}
|
||||||
@ -85411,18 +85411,20 @@ function downloadLatest(platform, arch, checkSum, githubToken) {
|
|||||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||||
const downloadPath = yield tc.downloadTool(downloadUrl, undefined, githubToken);
|
const downloadPath = yield tc.downloadTool(downloadUrl, undefined, githubToken);
|
||||||
let uvExecutablePath;
|
let uvExecutablePath;
|
||||||
let extractedDir;
|
let uvDir;
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
extractedDir = yield tc.extractZip(downloadPath);
|
const extractedDir = yield tc.extractZip(downloadPath);
|
||||||
uvExecutablePath = path.join(extractedDir, 'uv.exe');
|
uvDir = path.join(extractedDir, artifact);
|
||||||
|
uvExecutablePath = path.join(uvDir, 'uv.exe');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
extractedDir = yield tc.extractTar(downloadPath);
|
const extractedDir = yield tc.extractTar(downloadPath);
|
||||||
|
uvDir = path.join(extractedDir, artifact);
|
||||||
uvExecutablePath = path.join(extractedDir, 'uv');
|
uvExecutablePath = path.join(extractedDir, 'uv');
|
||||||
}
|
}
|
||||||
const version = yield getVersion(uvExecutablePath);
|
const version = yield getVersion(uvExecutablePath);
|
||||||
yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version);
|
yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version);
|
||||||
const cachedToolDir = yield tc.cacheDir(extractedDir, utils_1.TOOL_CACHE_NAME, version, arch);
|
const cachedToolDir = yield tc.cacheDir(uvDir, utils_1.TOOL_CACHE_NAME, version, arch);
|
||||||
return { cachedToolDir, version };
|
return { cachedToolDir, version };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -85492,11 +85494,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||||||
exports.downloadVersion = exports.tryGetFromToolCache = void 0;
|
exports.downloadVersion = exports.tryGetFromToolCache = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const utils_1 = __nccwpck_require__(239);
|
const utils_1 = __nccwpck_require__(239);
|
||||||
const checksum_1 = __nccwpck_require__(4622);
|
const checksum_1 = __nccwpck_require__(4622);
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
|
||||||
const util = __importStar(__nccwpck_require__(3837));
|
|
||||||
const readdir = util.promisify(fs.readdir);
|
|
||||||
function tryGetFromToolCache(arch, version) {
|
function tryGetFromToolCache(arch, version) {
|
||||||
core.debug(`Trying to get uv from tool cache for ${version}...`);
|
core.debug(`Trying to get uv from tool cache for ${version}...`);
|
||||||
const cachedVersions = tc.findAllVersions(utils_1.TOOL_CACHE_NAME, arch);
|
const cachedVersions = tc.findAllVersions(utils_1.TOOL_CACHE_NAME, arch);
|
||||||
@ -85506,8 +85506,8 @@ function tryGetFromToolCache(arch, version) {
|
|||||||
exports.tryGetFromToolCache = tryGetFromToolCache;
|
exports.tryGetFromToolCache = tryGetFromToolCache;
|
||||||
function downloadVersion(platform, arch, version, checkSum, githubToken) {
|
function downloadVersion(platform, arch, version, checkSum, githubToken) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const binary = `uv-${arch}-${platform}`;
|
const artifact = `uv-${arch}-${platform}`;
|
||||||
let downloadUrl = `https://github.com/${utils_1.OWNER}/${utils_1.REPO}/releases/download/${version}/${binary}`;
|
let downloadUrl = `https://github.com/${utils_1.OWNER}/${utils_1.REPO}/releases/download/${version}/${artifact}`;
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
downloadUrl += '.zip';
|
downloadUrl += '.zip';
|
||||||
}
|
}
|
||||||
@ -85524,11 +85524,7 @@ function downloadVersion(platform, arch, version, checkSum, githubToken) {
|
|||||||
else {
|
else {
|
||||||
extractedDir = yield tc.extractTar(downloadPath);
|
extractedDir = yield tc.extractTar(downloadPath);
|
||||||
}
|
}
|
||||||
core.info(`Extracted uv to "${extractedDir}"`);
|
return yield tc.cacheDir(path.join(extractedDir, artifact), utils_1.TOOL_CACHE_NAME, version, arch);
|
||||||
// list the contents of extracted dir
|
|
||||||
const files = yield readdir(extractedDir);
|
|
||||||
core.info(`Contents of extracted directory: ${files.join(', ')}`);
|
|
||||||
return yield tc.cacheDir(extractedDir, utils_1.TOOL_CACHE_NAME, version, arch);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.downloadVersion = downloadVersion;
|
exports.downloadVersion = downloadVersion;
|
||||||
|
@ -12,8 +12,8 @@ export async function downloadLatest(
|
|||||||
checkSum: string | undefined,
|
checkSum: string | undefined,
|
||||||
githubToken: string | undefined
|
githubToken: string | undefined
|
||||||
): Promise<{cachedToolDir: string; version: string}> {
|
): Promise<{cachedToolDir: string; version: string}> {
|
||||||
const binary = `uv-${arch}-${platform}`
|
const artifact = `uv-${arch}-${platform}`
|
||||||
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${binary}`
|
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}`
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
downloadUrl += '.zip'
|
downloadUrl += '.zip'
|
||||||
} else {
|
} else {
|
||||||
@ -27,22 +27,19 @@ export async function downloadLatest(
|
|||||||
githubToken
|
githubToken
|
||||||
)
|
)
|
||||||
let uvExecutablePath: string
|
let uvExecutablePath: string
|
||||||
let extractedDir: string
|
let uvDir: string
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
extractedDir = await tc.extractZip(downloadPath)
|
const extractedDir = await tc.extractZip(downloadPath)
|
||||||
uvExecutablePath = path.join(extractedDir, 'uv.exe')
|
uvDir = path.join(extractedDir, artifact)
|
||||||
|
uvExecutablePath = path.join(uvDir, 'uv.exe')
|
||||||
} else {
|
} else {
|
||||||
extractedDir = await tc.extractTar(downloadPath)
|
const extractedDir = await tc.extractTar(downloadPath)
|
||||||
|
uvDir = path.join(extractedDir, artifact)
|
||||||
uvExecutablePath = path.join(extractedDir, 'uv')
|
uvExecutablePath = path.join(extractedDir, 'uv')
|
||||||
}
|
}
|
||||||
const version = await getVersion(uvExecutablePath)
|
const version = await getVersion(uvExecutablePath)
|
||||||
await validateChecksum(checkSum, downloadPath, arch, platform, version)
|
await validateChecksum(checkSum, downloadPath, arch, platform, version)
|
||||||
const cachedToolDir = await tc.cacheDir(
|
const cachedToolDir = await tc.cacheDir(uvDir, TOOL_CACHE_NAME, version, arch)
|
||||||
extractedDir,
|
|
||||||
TOOL_CACHE_NAME,
|
|
||||||
version,
|
|
||||||
arch
|
|
||||||
)
|
|
||||||
|
|
||||||
return {cachedToolDir, version}
|
return {cachedToolDir, version}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as tc from '@actions/tool-cache'
|
import * as tc from '@actions/tool-cache'
|
||||||
|
import * as path from 'path'
|
||||||
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
|
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
|
||||||
import {Architecture, Platform} from '../utils/platforms'
|
import {Architecture, Platform} from '../utils/platforms'
|
||||||
import {validateChecksum} from './checksum/checksum'
|
import {validateChecksum} from './checksum/checksum'
|
||||||
|
|
||||||
import * as fs from 'fs'
|
|
||||||
import * as util from 'util'
|
|
||||||
|
|
||||||
const readdir = util.promisify(fs.readdir)
|
|
||||||
|
|
||||||
export function tryGetFromToolCache(
|
export function tryGetFromToolCache(
|
||||||
arch: Architecture,
|
arch: Architecture,
|
||||||
version: string
|
version: string
|
||||||
@ -26,8 +22,8 @@ export async function downloadVersion(
|
|||||||
checkSum: string | undefined,
|
checkSum: string | undefined,
|
||||||
githubToken: string | undefined
|
githubToken: string | undefined
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const binary = `uv-${arch}-${platform}`
|
const artifact = `uv-${arch}-${platform}`
|
||||||
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${binary}`
|
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}`
|
||||||
if (platform === 'pc-windows-msvc') {
|
if (platform === 'pc-windows-msvc') {
|
||||||
downloadUrl += '.zip'
|
downloadUrl += '.zip'
|
||||||
} else {
|
} else {
|
||||||
@ -48,10 +44,11 @@ export async function downloadVersion(
|
|||||||
} else {
|
} else {
|
||||||
extractedDir = await tc.extractTar(downloadPath)
|
extractedDir = await tc.extractTar(downloadPath)
|
||||||
}
|
}
|
||||||
core.info(`Extracted uv to "${extractedDir}"`)
|
|
||||||
// list the contents of extracted dir
|
|
||||||
const files = await readdir(extractedDir)
|
|
||||||
core.info(`Contents of extracted directory: ${files.join(', ')}`)
|
|
||||||
|
|
||||||
return await tc.cacheDir(extractedDir, TOOL_CACHE_NAME, version, arch)
|
return await tc.cacheDir(
|
||||||
|
path.join(extractedDir, artifact),
|
||||||
|
TOOL_CACHE_NAME,
|
||||||
|
version,
|
||||||
|
arch
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user