generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (39 loc) · 1.42 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
45
46
47
48
49
const core = require('@actions/core');
const exec = require('@actions/exec');
const fs = require('fs');
const os = require('os');
const path = require('path');
function is_yes(value) {
return ['yes', 'true'].includes(value.toLowerCase());
}
async function run() {
try {
const version = core.getInput('version');
const preview = is_yes(core.getInput('preview'));
const createVirtualenvs = is_yes(core.getInput('create_virtualenvs'));
core.startGroup('Retrieving Poetry Installation Script');
await exec.exec('curl -sSL -o install-poetry.py https://install.python-poetry.org');
core.endGroup();
core.startGroup('Installing Poetry');
const flags = preview ? '--preview' : version ? `--version=${version}` : '';
await exec.exec(`python install-poetry.py --yes ${flags}`);
core.endGroup();
core.startGroup('Configuring environment');
if (process.env['RUNNER_OS'] === 'Windows') {
core.addPath(path.join(os.homedir(), 'AppData', 'Roaming', 'Python', 'Scripts'));
} else {
core.addPath(path.join(os.homedir(), '.local', 'bin'));
}
core.info(`Path set to: ${process.env['PATH']}`);
if (!createVirtualenvs) {
await exec.exec('poetry config virtualenvs.create false');
}
core.endGroup();
core.startGroup('Cleaning up...');
fs.unlinkSync('install-poetry.py');
core.endGroup();
} catch (error) {
core.setFailed(error.message);
}
}
run();