mirror of
https://github.com/actions/setup-python.git
synced 2025-07-05 00:53:46 +00:00
update to v4, remove python-version default
* python-version overrides python-version-file, like setup-node * checks '.python-version' by default if nothing else specified
This commit is contained in:
parent
dbfda6e73c
commit
abfae9a57a
4 changed files with 38 additions and 31 deletions
|
@ -24,22 +24,30 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
|
|||
|
||||
function resolveVersionInput(): string {
|
||||
let version = core.getInput('python-version');
|
||||
const versionFileInput = core.getInput('python-version-file');
|
||||
const versionFile = core.getInput('python-version-file');
|
||||
|
||||
if (versionFileInput) {
|
||||
const versionFilePath = path.join(
|
||||
process.env.GITHUB_WORKSPACE!,
|
||||
versionFileInput
|
||||
if (version && versionFile) {
|
||||
core.warning(
|
||||
'Both python-version and python-version-file inputs are specified, only python-version will be used'
|
||||
);
|
||||
if (!fs.existsSync(versionFilePath)) {
|
||||
throw new Error(
|
||||
`The specified node version file at: ${versionFilePath} does not exist`
|
||||
);
|
||||
}
|
||||
version = fs.readFileSync(versionFilePath, 'utf8');
|
||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||
}
|
||||
|
||||
if (version) {
|
||||
return version;
|
||||
}
|
||||
|
||||
const versionFilePath = path.join(
|
||||
process.env.GITHUB_WORKSPACE!,
|
||||
versionFile || ".python-version"
|
||||
);
|
||||
if (!fs.existsSync(versionFilePath)) {
|
||||
throw new Error(
|
||||
`The specified python version file at: ${versionFilePath} does not exist`
|
||||
);
|
||||
}
|
||||
version = fs.readFileSync(versionFilePath, 'utf8');
|
||||
core.info(`Resolved ${versionFile} as ${version}`);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue