fix 🐛 when extracting

This commit is contained in:
Mark Delk 2023-11-26 00:50:06 -06:00
parent 8269bac1f7
commit 11ef85623b
4 changed files with 34 additions and 8 deletions

19
dist/index.js vendored
View File

@ -80701,10 +80701,16 @@ var require_versions = __commonJS({
darwin: "macos-x86_64", darwin: "macos-x86_64",
win32: "windows-x86_64" win32: "windows-x86_64"
}[platform]; }[platform];
const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version2}.${ext}`; const fileWithoutFileType = `zig-${addrhost}-${version2}`;
const downloadUrl = `https://ziglang.org/builds/${fileWithoutFileType}.${ext}`;
const versionWithoutBuildHash = semver2.clean(version2); const versionWithoutBuildHash = semver2.clean(version2);
const variantName = `zig-${addrhost}-${versionWithoutBuildHash}`; const variantName = `zig-${addrhost}-${versionWithoutBuildHash}`;
return { downloadUrl, variantName, version: versionWithoutBuildHash }; return {
downloadUrl,
fileWithoutFileType,
variantName,
version: versionWithoutBuildHash
};
} }
__name(resolveCommit2, "resolveCommit"); __name(resolveCommit2, "resolveCommit");
function getJSON(opts) { function getJSON(opts) {
@ -80761,7 +80767,12 @@ var {
var TOOL_NAME = "zig"; var TOOL_NAME = "zig";
async function downloadZig(platform, version2, useCache = true) { async function downloadZig(platform, version2, useCache = true) {
const ext = extForPlatform(platform); const ext = extForPlatform(platform);
const { downloadUrl, variantName, version: useVersion } = version2.includes("+") ? resolveCommit(platform, version2) : await resolveVersion(platform, version2); const {
downloadUrl,
fileWithoutFileType,
variantName,
version: useVersion
} = version2.includes("+") ? resolveCommit(platform, version2) : await resolveVersion(platform, version2);
const cachedPath = toolCache.find(TOOL_NAME, useVersion); const cachedPath = toolCache.find(TOOL_NAME, useVersion);
if (cachedPath) { if (cachedPath) {
actions.info(`using cached zig install: ${cachedPath}`); actions.info(`using cached zig install: ${cachedPath}`);
@ -80780,7 +80791,7 @@ async function downloadZig(platform, version2, useCache = true) {
actions.info(`no cached version found. downloading zig ${variantName}`); actions.info(`no cached version found. downloading zig ${variantName}`);
const downloadPath = await toolCache.downloadTool(downloadUrl); const downloadPath = await toolCache.downloadTool(downloadUrl);
const zigPath = ext === "zip" ? await toolCache.extractZip(downloadPath) : await toolCache.extractTar(downloadPath, void 0, "x"); const zigPath = ext === "zip" ? await toolCache.extractZip(downloadPath) : await toolCache.extractTar(downloadPath, void 0, "x");
const binPath = path.join(zigPath, variantName); const binPath = path.join(zigPath, fileWithoutFileType);
const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion); const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion);
if (useCache) { if (useCache) {
actions.info(`adding zig ${useVersion} at ${cachePath} to local cache ${cacheKey}`); actions.info(`adding zig ${useVersion} at ${cachePath} to local cache ${cacheKey}`);

View File

@ -17,7 +17,12 @@ const TOOL_NAME = 'zig'
async function downloadZig (platform, version, useCache = true) { async function downloadZig (platform, version, useCache = true) {
const ext = extForPlatform(platform) const ext = extForPlatform(platform)
const { downloadUrl, variantName, version: useVersion } = version.includes('+') const {
downloadUrl,
fileWithoutFileType,
variantName,
version: useVersion
} = version.includes('+')
? resolveCommit(platform, version) ? resolveCommit(platform, version)
: await resolveVersion(platform, version) : await resolveVersion(platform, version)
@ -44,7 +49,7 @@ async function downloadZig (platform, version, useCache = true) {
? await toolCache.extractZip(downloadPath) ? await toolCache.extractZip(downloadPath)
: await toolCache.extractTar(downloadPath, undefined, 'x') : await toolCache.extractTar(downloadPath, undefined, 'x')
const binPath = path.join(zigPath, variantName) const binPath = path.join(zigPath, fileWithoutFileType)
const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion) const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion)
if (useCache) { if (useCache) {

View File

@ -7,21 +7,25 @@ const {
async function test () { async function test () {
assert.deepEqual(resolveCommit('linux', '0.6.0+4b48fccad'), { assert.deepEqual(resolveCommit('linux', '0.6.0+4b48fccad'), {
downloadUrl: 'https://ziglang.org/builds/zig-linux-x86_64-0.6.0+4b48fccad.tar.xz', downloadUrl: 'https://ziglang.org/builds/zig-linux-x86_64-0.6.0+4b48fccad.tar.xz',
fileWithoutFileType: 'zig-linux-x86_64-0.6.0+4b48fccad',
variantName: 'zig-linux-x86_64-0.6.0', variantName: 'zig-linux-x86_64-0.6.0',
version: '0.6.0' version: '0.6.0'
}) })
assert.deepEqual(resolveCommit('win32', '0.6.0+4b48fccad'), { assert.deepEqual(resolveCommit('win32', '0.6.0+4b48fccad'), {
downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.6.0+4b48fccad.zip', downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.6.0+4b48fccad.zip',
fileWithoutFileType: 'zig-windows-x86_64-0.6.0+4b48fccad',
variantName: 'zig-windows-x86_64-0.6.0', variantName: 'zig-windows-x86_64-0.6.0',
version: '0.6.0' version: '0.6.0'
}) })
assert.deepEqual(resolveCommit('win32', '0.12.0-dev.1092+68ed78775'), { assert.deepEqual(resolveCommit('win32', '0.12.0-dev.1092+68ed78775'), {
downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.12.0-dev.1092+68ed78775.zip', downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.12.0-dev.1092+68ed78775.zip',
fileWithoutFileType: 'zig-windows-x86_64-0.12.0-dev.1092+68ed78775',
variantName: 'zig-windows-x86_64-0.12.0-dev.1092', variantName: 'zig-windows-x86_64-0.12.0-dev.1092',
version: '0.12.0-dev.1092' version: '0.12.0-dev.1092'
}) })
assert.deepEqual(resolveCommit('darwin', '0.12.0-dev.1150+3c22cecee'), { assert.deepEqual(resolveCommit('darwin', '0.12.0-dev.1150+3c22cecee'), {
downloadUrl: 'https://ziglang.org/builds/zig-macos-x86_64-0.12.0-dev.1150+3c22cecee.tar.xz', downloadUrl: 'https://ziglang.org/builds/zig-macos-x86_64-0.12.0-dev.1150+3c22cecee.tar.xz',
fileWithoutFileType: 'zig-macos-x86_64-0.12.0-dev.1150+3c22cecee',
variantName: 'zig-macos-x86_64-0.12.0-dev.1150', variantName: 'zig-macos-x86_64-0.12.0-dev.1150',
version: '0.12.0-dev.1150' version: '0.12.0-dev.1150'
}) })

View File

@ -18,12 +18,18 @@ function resolveCommit (platform, version) {
win32: 'windows-x86_64' win32: 'windows-x86_64'
}[platform] }[platform]
const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}` const fileWithoutFileType = `zig-${addrhost}-${version}`
const downloadUrl = `https://ziglang.org/builds/${fileWithoutFileType}.${ext}`
const versionWithoutBuildHash = semver.clean(version) const versionWithoutBuildHash = semver.clean(version)
const variantName = `zig-${addrhost}-${versionWithoutBuildHash}` const variantName = `zig-${addrhost}-${versionWithoutBuildHash}`
return { downloadUrl, variantName, version: versionWithoutBuildHash } return {
downloadUrl,
fileWithoutFileType,
variantName,
version: versionWithoutBuildHash
}
} }
function getJSON (opts) { function getJSON (opts) {