Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
Xuanwo
2023-01-09 23:47:21 +08:00
parent 5b9624008f
commit a2811a1f48
2 changed files with 22 additions and 8 deletions
+8 -3
View File
@@ -47,20 +47,22 @@ function setup() {
// is not input. // is not input.
const version = core.getInput('version'); const version = core.getInput('version');
console.log('try to setup sccache version: ', 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); console.log('sccache download from url: ', downloadUrl);
// Download and extract. // Download and extract.
const sccachePackage = yield (0, tool_cache_1.downloadTool)(downloadUrl); const sccachePackage = yield (0, tool_cache_1.downloadTool)(downloadUrl);
var sccachePath; var sccachePath;
if (getExtension() == 'zip') { if (getExtension() == 'zip') {
sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); sccachePath = yield (0, tool_cache_1.extractZip)(sccachePackage);
} }
else { else {
sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage);
} }
console.log('sccache extracted to: ', sccachePath); console.log('sccache extracted to: ', sccachePath);
// Cache sccache. // 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); console.log('sccache cached to: ', sccacheHome);
// Add cached sccache into path. // Add cached sccache into path.
core.addPath(`${sccacheHome}`); core.addPath(`${sccacheHome}`);
@@ -71,6 +73,9 @@ function setup() {
function getFilename(version) { function getFilename(version) {
return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`; return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`;
} }
function getDirname(version) {
return `sccache-${version}-${getArch()}-${getPlatform()}}`;
}
function getArch() { function getArch() {
switch (process.arch) { switch (process.arch) {
case 'x64': case 'x64':
+14 -5
View File
@@ -15,9 +15,10 @@ async function setup() {
const version = core.getInput('version'); const version = core.getInput('version');
console.log('try to setup sccache version: ', version); console.log('try to setup sccache version: ', version);
const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${getFilename( const filename = getFilename(version);
version const dirname = getDirname(version);
)}`;
const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${filename}`;
console.log('sccache download from url: ', downloadUrl); console.log('sccache download from url: ', downloadUrl);
// Download and extract. // Download and extract.
@@ -25,14 +26,18 @@ async function setup() {
var sccachePath; var sccachePath;
if (getExtension() == 'zip') { if (getExtension() == 'zip') {
sccachePath = await extractTar(sccachePackage); sccachePath = await extractZip(sccachePackage);
} else { } else {
sccachePath = await extractTar(sccachePackage); sccachePath = await extractTar(sccachePackage);
} }
console.log('sccache extracted to: ', sccachePath); console.log('sccache extracted to: ', sccachePath);
// Cache sccache. // Cache sccache.
const sccacheHome = await cacheDir(sccachePath, 'sccache', version); const sccacheHome = await cacheDir(
`${sccachePath}/${dirname}`,
'sccache',
version
);
console.log('sccache cached to: ', sccacheHome); console.log('sccache cached to: ', sccacheHome);
// Add cached sccache into path. // Add cached sccache into path.
@@ -45,6 +50,10 @@ function getFilename(version: string): Error | string {
return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`; return `sccache-${version}-${getArch()}-${getPlatform()}.${getExtension()}`;
} }
function getDirname(version: string): Error | string {
return `sccache-${version}-${getArch()}-${getPlatform()}}`;
}
function getArch(): Error | string { function getArch(): Error | string {
switch (process.arch) { switch (process.arch) {
case 'x64': case 'x64':