mirror of
https://github.com/mozilla-actions/sccache-action
synced 2026-09-14 20:13:56 +00:00
Vendored
+8
-3
@@ -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
@@ -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':
|
||||||
|
|||||||
Reference in New Issue
Block a user