-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const path = require('path');
const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const exec = require('@actions/exec');
const { getDownloadObject } = require('./lib/utils');
const { getImage } = require('./lib/utils');
async function setup() {
try {
// Get version of tool to be installed
const version = core.getInput('version');
// Get OS image
const image = await getImage();
// Download the specific version of the tool, e.g. as a tarball/zipball
const download = getDownloadObject(version, image);
const pathToTarball = await tc.downloadTool(download.url);
// Extract the tarball/zipball onto host runner
const extract = download.url.endsWith('.zip') ? tc.extractZip : tc.extractTar;
const pathToCLI = await extract(pathToTarball);
// Expose the tool by adding it to the PATH
core.addPath(path.join(pathToCLI, download.binPath));
if (image === 'ubuntu-22.04') {
await exec.exec('sudo apt-get install -y ccache mold');
}
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup();
}