1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-09 04:42:20 +02:00

Add check-latest functionality (#406)

This commit is contained in:
Dmitry Shibanov 2022-07-25 16:54:04 +02:00 committed by GitHub
parent 49a521fa06
commit 2f06e9da25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 440 additions and 82 deletions

View file

@ -33,12 +33,34 @@ function binDir(installDir: string): string {
export async function useCpythonVersion(
version: string,
architecture: string,
updateEnvironment: boolean
updateEnvironment: boolean,
checkLatest: boolean
): 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}`);
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,
@ -50,7 +72,8 @@ export async function useCpythonVersion(
);
const foundRelease = await installer.findReleaseFromManifest(
semanticVersionSpec,
architecture
architecture,
manifest
);
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {