mirror of
https://gitea.com/actions/setup-python.git
synced 2025-09-18 09:38:25 +08:00
Add check-latest functionality (#406)
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user