From 07977d064ca4a8a3b528e05205932d1b3cb5c52d Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sat, 24 Aug 2024 00:27:50 +0200 Subject: [PATCH] Automatically create download dir --- dist/setup/index.js | 21 +++++++++++++-------- src/download/download-latest.ts | 7 +++---- src/download/download-version.ts | 12 ++++++------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index b30598c..6761126 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -85394,8 +85394,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.downloadLatest = void 0; const core = __importStar(__nccwpck_require__(2186)); const tc = __importStar(__nccwpck_require__(7784)); -const path = __importStar(__nccwpck_require__(1017)); const exec = __importStar(__nccwpck_require__(1514)); +const io = __importStar(__nccwpck_require__(7436)); +const path = __importStar(__nccwpck_require__(1017)); const checksum_1 = __nccwpck_require__(4622); const utils_1 = __nccwpck_require__(239); function downloadLatest(platform, arch, checkSum, githubToken) { @@ -85409,7 +85410,8 @@ function downloadLatest(platform, arch, checkSum, githubToken) { downloadUrl += '.tar.gz'; } core.info(`Downloading uv from "${downloadUrl}" ...`); - const downloadDir = `${process.cwd()}${path.sep}uv`; + const downloadDir = path.join(process.env['RUNNER_TEMP'] || '', 'uv-download'); + yield io.mkdirP(downloadDir); const downloadPath = yield tc.downloadTool(downloadUrl, downloadDir, githubToken); let uvExecutablePath; let extracted; @@ -85422,7 +85424,7 @@ function downloadLatest(platform, arch, checkSum, githubToken) { uvExecutablePath = path.join(extracted, 'uv'); } const version = yield getVersion(uvExecutablePath); - yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version); + yield (0, checksum_1.validateChecksum)(checkSum, extracted, arch, platform, version); const cachedToolDir = yield tc.cacheDir(downloadPath, utils_1.TOOL_CACHE_NAME, version, arch); return { cachedToolDir, version }; }); @@ -85496,8 +85498,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.downloadVersion = exports.tryGetFromToolCache = void 0; const core = __importStar(__nccwpck_require__(2186)); const tc = __importStar(__nccwpck_require__(7784)); -const utils_1 = __nccwpck_require__(239); +const io = __importStar(__nccwpck_require__(7436)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const utils_1 = __nccwpck_require__(239); const checksum_1 = __nccwpck_require__(4622); function tryGetFromToolCache(arch, version) { core.debug(`Trying to get uv from tool cache for ${version}...`); @@ -85517,16 +85520,18 @@ function downloadVersion(platform, arch, version, checkSum, githubToken) { downloadUrl += '.tar.gz'; } core.info(`Downloading uv from "${downloadUrl}" ...`); - const downloadDir = `${process.cwd()}${path_1.default.sep}uv`; + const downloadDir = path_1.default.join(process.env['RUNNER_TEMP'] || '', 'uv-download'); + yield io.mkdirP(downloadDir); const downloadPath = yield tc.downloadTool(downloadUrl, downloadDir, githubToken); yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version); + let extractedDir; if (platform === 'pc-windows-msvc') { - yield tc.extractZip(downloadPath); + extractedDir = yield tc.extractZip(downloadPath); } else { - tc.extractTar(downloadPath); + extractedDir = yield tc.extractTar(downloadPath); } - return yield tc.cacheDir(downloadPath, utils_1.TOOL_CACHE_NAME, version, arch); + return yield tc.cacheDir(extractedDir, utils_1.TOOL_CACHE_NAME, version, arch); }); } exports.downloadVersion = downloadVersion; diff --git a/src/download/download-latest.ts b/src/download/download-latest.ts index 5690f77..9311358 100644 --- a/src/download/download-latest.ts +++ b/src/download/download-latest.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core' import * as tc from '@actions/tool-cache' -import * as path from 'path' 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/utils' @@ -21,10 +21,9 @@ export async function downloadLatest( } core.info(`Downloading uv from "${downloadUrl}" ...`) - const downloadDir = `${process.cwd()}${path.sep}uv` const downloadPath = await tc.downloadTool( downloadUrl, - downloadDir, + undefined, githubToken ) let uvExecutablePath: string @@ -37,7 +36,7 @@ export async function downloadLatest( uvExecutablePath = path.join(extracted, 'uv') } const version = await getVersion(uvExecutablePath) - await validateChecksum(checkSum, downloadPath, arch, platform, version) + await validateChecksum(checkSum, extracted, arch, platform, version) const cachedToolDir = await tc.cacheDir( downloadPath, TOOL_CACHE_NAME, diff --git a/src/download/download-version.ts b/src/download/download-version.ts index e136e49..896492f 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core' import * as tc from '@actions/tool-cache' -import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils' import path from 'path' +import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils' import {Architecture, Platform} from '../utils/platforms' import {validateChecksum} from './checksum/checksum' @@ -31,18 +31,18 @@ export async function downloadVersion( } core.info(`Downloading uv from "${downloadUrl}" ...`) - const downloadDir = `${process.cwd()}${path.sep}uv` const downloadPath = await tc.downloadTool( downloadUrl, - downloadDir, + undefined, githubToken ) await validateChecksum(checkSum, downloadPath, arch, platform, version) + let extractedDir: string if (platform === 'pc-windows-msvc') { - await tc.extractZip(downloadPath) + extractedDir = await tc.extractZip(downloadPath) } else { - tc.extractTar(downloadPath) + extractedDir = await tc.extractTar(downloadPath) } - return await tc.cacheDir(downloadPath, TOOL_CACHE_NAME, version, arch) + return await tc.cacheDir(extractedDir, TOOL_CACHE_NAME, version, arch) }