-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (32 loc) · 1.05 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
40
41
42
43
44
const core = require('@actions/core');
const exec = require('@actions/exec');
const tc = require('@actions/tool-cache');
async function run() {
try {
let version = core.getInput('version');
let downloadURL = core.getInput('download_url');
const fillTemplate = function(s) {
s = s.replace(/\$\{version\}/g, version)
return s
}
downloadURL = fillTemplate(downloadURL);
core.info(`changelog donwload URL: ${downloadURL}`)
await installTool(version, downloadURL);
await exec.exec('changelog version');
} catch (error) {
core.setFailed(error.message);
}
}
async function installTool(version, url) {
let cachedPath = tc.find('changelog', version)
if (cachedPath) {
core.addPath(cachedPath)
return
}
const file = await tc.downloadTool(url);
await exec.exec(`mkdir changelog`)
await exec.exec(`tar -C changelog -xzvf ${file} --strip-components 0 --wildcards changelog`)
cachedPath = await tc.cacheDir('changelog', 'changelog', version);
core.addPath(cachedPath)
}
run();