mirror of
https://github.com/Mozilla-Actions/sccache-action.git
synced 2026-04-08 17:42:13 +08:00
11
dist/index.js
vendored
11
dist/index.js
vendored
@@ -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':
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user