-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (31 loc) · 1.18 KB
/
Copy pathindex.js
File metadata and controls
39 lines (31 loc) · 1.18 KB
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');
function getDownloadURL(version) {
url = `https://github.com/cargo-lambda/cargo-lambda/releases/download/${version}/cargo-lambda-${version}.x86_64-unknown-linux-musl.tar.gz`;
return url
}
async function setup() {
// Get version of tool to be installed
const version = core.getInput('version');
console.log(`Input version is: ${version}`);
// Download the specific version of the tool, e.g. as a tarball
const downloadUrl = getDownloadURL(version);
console.log(`Download url is: ${downloadUrl}`)
const downloadPath = await tc.downloadTool(downloadUrl);
console.log(`Downloaded path is: ${downloadPath}`)
// Extract the tarball onto the runner
const cargoLambdaPath = await tc.extractTar(downloadPath);
console.log(`Extracted path is: ${cargoLambdaPath}`)
const cachePath = await tc.cacheDir(cargoLambdaPath, 'cargo-lambda', version)
// Expose the tool by adding it to the PATH
console.log(`Adding ${cachePath} to PATH`);
core.addPath(cachePath)
}
(async () => {
try {
await setup();
} catch (error) {
core.setFailed(error.message);
}
})();