From 7c910b8107268186256c738e9cf15dc48ecc835b Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Tue, 5 Nov 2024 20:07:21 +0100 Subject: [PATCH] add archive extension to downloaded assets Fixes missing .zip extensions which breaks on old PowerShell versions --- dist/setup/index.js | 20 ++++++++++---------- src/download/download-latest.ts | 11 ++++++----- src/download/download-version.ts | 11 ++++++----- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index ab3c5e1..a7c9c15 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -89845,16 +89845,16 @@ const checksum_1 = __nccwpck_require__(5391); const constants_1 = __nccwpck_require__(6156); function downloadLatest(platform, arch, checkSum, githubToken) { return __awaiter(this, void 0, void 0, function* () { - const artifact = `uv-${arch}-${platform}`; - let downloadUrl = `https://github.com/${constants_1.OWNER}/${constants_1.REPO}/releases/latest/download/${artifact}`; + let artifact = `uv-${arch}-${platform}`; if (platform === "pc-windows-msvc") { - downloadUrl += ".zip"; + artifact += ".zip"; } else { - downloadUrl += ".tar.gz"; + artifact += ".tar.gz"; } + const downloadUrl = `https://github.com/${constants_1.OWNER}/${constants_1.REPO}/releases/latest/download/${artifact}`; core.info(`Downloading uv from "${downloadUrl}" ...`); - const downloadPath = yield tc.downloadTool(downloadUrl, undefined, githubToken); + const downloadPath = yield tc.downloadTool(downloadUrl, artifact, githubToken); let uvExecutablePath; let uvDir; if (platform === "pc-windows-msvc") { @@ -89957,16 +89957,16 @@ function tryGetFromToolCache(arch, version) { function downloadVersion(platform, arch, version, checkSum, githubToken) { return __awaiter(this, void 0, void 0, function* () { const resolvedVersion = yield resolveVersion(version, githubToken); - const artifact = `uv-${arch}-${platform}`; - let downloadUrl = `https://github.com/${constants_1.OWNER}/${constants_1.REPO}/releases/download/${resolvedVersion}/${artifact}`; + let artifact = `uv-${arch}-${platform}`; if (platform === "pc-windows-msvc") { - downloadUrl += ".zip"; + artifact += ".zip"; } else { - downloadUrl += ".tar.gz"; + artifact += ".tar.gz"; } + const downloadUrl = `https://github.com/${constants_1.OWNER}/${constants_1.REPO}/releases/download/${resolvedVersion}/${artifact}`; core.info(`Downloading uv from "${downloadUrl}" ...`); - const downloadPath = yield tc.downloadTool(downloadUrl, undefined, githubToken); + const downloadPath = yield tc.downloadTool(downloadUrl, artifact, githubToken); yield (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, resolvedVersion); let uvDir; if (platform === "pc-windows-msvc") { diff --git a/src/download/download-latest.ts b/src/download/download-latest.ts index 6f173e0..9388b40 100644 --- a/src/download/download-latest.ts +++ b/src/download/download-latest.ts @@ -2,6 +2,7 @@ import * as core from "@actions/core"; import * as tc from "@actions/tool-cache"; import * as exec from "@actions/exec"; import * as path from "node:path"; +import { promises as fs } from "node:fs"; import type { Architecture, Platform } from "../utils/platforms"; import { validateChecksum } from "./checksum/checksum"; import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants"; @@ -12,18 +13,18 @@ export async function downloadLatest( checkSum: string | undefined, githubToken: string | undefined, ): Promise<{ cachedToolDir: string; version: string }> { - const artifact = `uv-${arch}-${platform}`; - let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}`; + let artifact = `uv-${arch}-${platform}`; if (platform === "pc-windows-msvc") { - downloadUrl += ".zip"; + artifact += ".zip"; } else { - downloadUrl += ".tar.gz"; + artifact += ".tar.gz"; } + const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}`; core.info(`Downloading uv from "${downloadUrl}" ...`); const downloadPath = await tc.downloadTool( downloadUrl, - undefined, + artifact, githubToken, ); let uvExecutablePath: string; diff --git a/src/download/download-version.ts b/src/download/download-version.ts index b6123e6..b9c013d 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -1,6 +1,7 @@ import * as core from "@actions/core"; import * as tc from "@actions/tool-cache"; import * as path from "node:path"; +import { promises as fs } from "node:fs"; import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants"; import type { Architecture, Platform } from "../utils/platforms"; import { validateChecksum } from "./checksum/checksum"; @@ -29,18 +30,18 @@ export async function downloadVersion( githubToken: string, ): Promise<{ version: string; cachedToolDir: string }> { const resolvedVersion = await resolveVersion(version, githubToken); - const artifact = `uv-${arch}-${platform}`; - let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}`; + let artifact = `uv-${arch}-${platform}`; if (platform === "pc-windows-msvc") { - downloadUrl += ".zip"; + artifact += ".zip"; } else { - downloadUrl += ".tar.gz"; + artifact += ".tar.gz"; } + const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}`; core.info(`Downloading uv from "${downloadUrl}" ...`); const downloadPath = await tc.downloadTool( downloadUrl, - undefined, + artifact, githubToken, ); await validateChecksum(