-
Notifications
You must be signed in to change notification settings - Fork 569
/
setup-python.ts
35 lines (32 loc) · 1.08 KB
/
setup-python.ts
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
import * as core from '@actions/core';
import * as finder from './find-python';
import * as finderPyPy from './find-pypy';
import * as path from 'path';
import * as os from 'os';
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy-');
}
async function run() {
try {
let version = core.getInput('python-version');
if (version) {
const arch: string = core.getInput('architecture') || os.arch();
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch);
core.info(
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
);
} else {
const installed = await finder.findPythonVersion(version, arch);
core.info(
`Successfully setup ${installed.impl} (${installed.version})`
);
}
}
const matchersPath = path.join(__dirname, '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
} catch (err) {
core.setFailed(err.message);
}
}
run();