Add ability to download specific version of Python from releases

This commit is contained in:
MaksimZhukov 2020-04-24 20:29:24 +03:00
parent 985150d1f6
commit 81b3a118a7
9 changed files with 4063 additions and 3618 deletions

View file

@ -3,6 +3,8 @@ import * as path from 'path';
import * as semver from 'semver';
import * as installer from './install-python';
let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
if (!cacheDirectory) {
@ -92,29 +94,31 @@ async function useCpythonVersion(
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
const installDir: string | null = tc.find(
let installDir: string | null = tc.find(
'Python',
semanticVersionSpec,
architecture
);
if (!installDir) {
// Fail and list available versions
const x86Versions = tc
.findAllVersions('Python', 'x86')
.map(s => `${s} (x86)`)
.join(os.EOL);
core.info(`Version ${semanticVersionSpec} is not found in local cache`);
const foundRelease = await installer.findReleaseFromManifest(
semanticVersionSpec,
architecture
);
const x64Versions = tc
.findAllVersions('Python', 'x64')
.map(s => `${s} (x64)`)
.join(os.EOL);
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
core.info(`Version ${semanticVersionSpec} is available for downloading`);
await installer.installCpythonFromRelease(foundRelease);
installDir = tc.find('Python', semanticVersionSpec, architecture);
}
}
if (!installDir) {
throw new Error(
[
`Version ${version} with arch ${architecture} not found`,
'Available versions:',
x86Versions,
x64Versions
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
].join(os.EOL)
);
}