diff --git a/dist/index.js b/dist/index.js index 0c02c44..d2a640f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -47,20 +47,22 @@ function setup() { // is not input. const version = core.getInput('version'); console.log('try to setup sccache version: ', version); - const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${getFilename(version)}`; + const filename = getFilename(version); + const dirname = getDirname(version); + const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${filename}`; console.log('sccache download from url: ', downloadUrl); // Download and extract. const sccachePackage = yield (0, tool_cache_1.downloadTool)(downloadUrl); var sccachePath; if (getExtension() == 'zip') { - sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); + sccachePath = yield (0, tool_cache_1.extractZip)(sccachePackage); } else { sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); } console.log('sccache extracted to: ', sccachePath); // Cache sccache. - const sccacheHome = yield (0, tool_cache_1.cacheDir)(sccachePath, 'sccache', version); + const sccacheHome = yield (0, tool_cache_1.cacheDir)(`${sccachePath}/${dirname}`, 'sccache', version); console.log('sccache cached to: ', sccacheHome); // Add cached sccache into path. core.addPath(`${sccacheHome}`); @@ -71,6 +73,9 @@ function setup() { function getFilename(version) { return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`; } +function getDirname(version) { + return `sccache-${version}-${getArch()}-${getPlatform()}}`; +} function getArch() { switch (process.arch) { case 'x64': diff --git a/src/sccache.ts b/src/sccache.ts index 869a761..6fe0cd7 100644 --- a/src/sccache.ts +++ b/src/sccache.ts @@ -15,9 +15,10 @@ async function setup() { const version = core.getInput('version'); console.log('try to setup sccache version: ', version); - const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${getFilename( - version - )}`; + const filename = getFilename(version); + const dirname = getDirname(version); + + const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${filename}`; console.log('sccache download from url: ', downloadUrl); // Download and extract. @@ -25,14 +26,18 @@ async function setup() { var sccachePath; if (getExtension() == 'zip') { - sccachePath = await extractTar(sccachePackage); + sccachePath = await extractZip(sccachePackage); } else { sccachePath = await extractTar(sccachePackage); } console.log('sccache extracted to: ', sccachePath); // Cache sccache. - const sccacheHome = await cacheDir(sccachePath, 'sccache', version); + const sccacheHome = await cacheDir( + `${sccachePath}/${dirname}`, + 'sccache', + version + ); console.log('sccache cached to: ', sccacheHome); // Add cached sccache into path. @@ -45,6 +50,10 @@ function getFilename(version: string): Error | string { return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`; } +function getDirname(version: string): Error | string { + return `sccache-${version}-${getArch()}-${getPlatform()}}`; +} + function getArch(): Error | string { switch (process.arch) { case 'x64':