-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.js
47 lines (38 loc) · 1.09 KB
/
run.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
45
46
47
const core = require('@actions/core');
const exec = require('@actions/exec');
function get_username() {
let result = process.env.CONAN_USERNAME;
if (!result) {
const repo = process.env.GITHUB_REPOSITORY || '';
result = (repo.split('/', 1) || [''])[0];
}
return result;
};
function get_cpt_version() {
const version = core.getInput('install');
let result = "conan_package_tools";
if ("no" == version) {
return null;
} if ("latest" != version) {
result = `${result}==${version}`;
}
return result;
};
async function run() {
const cpt_version = get_cpt_version();
if (cpt_version) {
console.log(`Installing ${cpt_version}...`)
await exec.exec('pip', ["install", cpt_version]);
}
const opts
= { env: Object.assign({CONAN_USERNAME: get_username()}, process.env)
};
const script = core.getInput('build-script');
console.log(`Running conan_package_tools with script ${script}...`)
await exec.exec('python', [core.getInput('build-script')], opts);
}
module.exports =
{ run: run
, get_username: get_username
, get_cpt_version: get_cpt_version
};