Automatically create download dir

This commit is contained in:
Kevin Stillhammer 2024-08-24 00:27:50 +02:00
parent 67efd41074
commit 07977d064c
No known key found for this signature in database
3 changed files with 22 additions and 18 deletions

21
dist/setup/index.js generated vendored
View File

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

View File

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

View File

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