generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.js
42 lines (35 loc) · 1.39 KB
/
setup.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
40
41
42
const core = require('@actions/core');
const io = require('@actions/io');
const exec = require('@actions/exec');
const tc = require('@actions/tool-cache');
const fs = require('fs');
const os = require('os');
const path = require('path');
async function run() {
const millPath = `.mill-bin`;
try {
const millVersion = core.getInput('mill-version');
var cachedMillPath = tc.find('mill', millVersion);
if (!cachedMillPath) {
core.info('no cached version found');
core.info('downloading mill');
const downloadPath = await tc.downloadTool(`https://github.com/lihaoyi/mill/releases/download/${millVersion}/${millVersion}-assembly`);
await io.mkdirP(millPath);
await io.cp(downloadPath, `${millPath}/mill`, { force: true });
fs.chmodSync(`${millPath}/mill`, '0755')
cachedMillPath = await tc.cacheDir(millPath, 'mill', millVersion);
} else {
core.info(`using cached version of mill: ${cachedMillPath}`);
}
core.addPath(cachedMillPath);
// warm up mill, this populates ~/.mill
// TODO: once caching across workflow invocations is available, this dorectory should be cached too
// (note that caching would only help for multiple jobs, as data is cached in the home directory
// which is shared across steps)
await exec.exec('mill', ['version']);
}
catch (error) {
core.setFailed(error.message);
}
}
run()