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",
win32: "windows-x86_64"
}[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 variantName = `zig-${addrhost}-${versionWithoutBuildHash}`;
return { downloadUrl, variantName, version: versionWithoutBuildHash };
return {
downloadUrl,
fileWithoutFileType,
variantName,
version: versionWithoutBuildHash
};
}
__name(resolveCommit2, "resolveCommit");
function getJSON(opts) {
@ -80761,7 +80767,12 @@ var {
var TOOL_NAME = "zig";
async function downloadZig(platform, version2, useCache = true) {
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);
if (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}`);
const downloadPath = await toolCache.downloadTool(downloadUrl);
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);
if (useCache) {
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) {
const ext = extForPlatform(platform)
const { downloadUrl, variantName, version: useVersion } = version.includes('+')
const {
downloadUrl,
fileWithoutFileType,
variantName,
version: useVersion
} = version.includes('+')
? resolveCommit(platform, version)
: await resolveVersion(platform, version)
@ -44,7 +49,7 @@ async function downloadZig (platform, version, useCache = true) {
? await toolCache.extractZip(downloadPath)
: 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)
if (useCache) {

View File

@ -7,21 +7,25 @@ const {
async function test () {
assert.deepEqual(resolveCommit('linux', '0.6.0+4b48fccad'), {
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',
version: '0.6.0'
})
assert.deepEqual(resolveCommit('win32', '0.6.0+4b48fccad'), {
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',
version: '0.6.0'
})
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',
fileWithoutFileType: 'zig-windows-x86_64-0.12.0-dev.1092+68ed78775',
variantName: 'zig-windows-x86_64-0.12.0-dev.1092',
version: '0.12.0-dev.1092'
})
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',
fileWithoutFileType: 'zig-macos-x86_64-0.12.0-dev.1150+3c22cecee',
variantName: 'zig-macos-x86_64-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'
}[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 variantName = `zig-${addrhost}-${versionWithoutBuildHash}`
return { downloadUrl, variantName, version: versionWithoutBuildHash }
return {
downloadUrl,
fileWithoutFileType,
variantName,
version: versionWithoutBuildHash
}
}
function getJSON (opts) {