add check-latest for python versions

This commit is contained in:
Dmitry Shibanov 2022-05-04 11:40:08 +02:00
parent ae11205ec6
commit 58a8109aea
9 changed files with 2136 additions and 1635 deletions

View file

@ -34,10 +34,25 @@ export async function useCpythonVersion(
version: string,
architecture: string
): Promise<InstalledVersion> {
let manifest: tc.IToolRelease[] | null = null;
const desugaredVersionSpec = desugarDevVersion(version);
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
const checkLatest = core.getBooleanInput('check-latest');
if (checkLatest) {
manifest = await installer.getManifest();
const resolvedVersion = (await installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))?.version;
if(resolvedVersion) {
semanticVersionSpec = resolvedVersion;
core.info(`Resolved as '${semanticVersionSpec}'`);
} else {
core.info(`Failed to resolve version ${semanticVersionSpec} from manifest`);
}
}
let installDir: string | null = tc.find(
'Python',
semanticVersionSpec,
@ -49,7 +64,8 @@ export async function useCpythonVersion(
);
const foundRelease = await installer.findReleaseFromManifest(
semanticVersionSpec,
architecture
architecture,
manifest
);
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {

View file

@ -14,20 +14,26 @@ export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_O
export async function findReleaseFromManifest(
semanticVersionSpec: string,
architecture: string
architecture: string,
manifest: tc.IToolRelease[] | null
): Promise<tc.IToolRelease | undefined> {
const manifest: tc.IToolRelease[] = await tc.getManifestFromRepo(
MANIFEST_REPO_OWNER,
MANIFEST_REPO_NAME,
AUTH,
MANIFEST_REPO_BRANCH
);
return await tc.findFromManifest(
if(!manifest) {
manifest = await getManifest();
}
const foundRelease = await tc.findFromManifest(
semanticVersionSpec,
false,
manifest,
architecture
);
return foundRelease;
}
export function getManifest(): Promise<tc.IToolRelease[]> {
core.debug(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`);
return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
}
async function installPython(workingDirectory: string) {