Skip to content

Commit e0b12dc

Browse files
Add support for python-version-file
1 parent 18e2d2f commit e0b12dc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: 'Version of python to be installed. Reads from .python-version if unset.'
66
python-version-file:
77
description: 'Version of python to be installed'
8-
default: ".python-version"
8+
default: '.python-version'
99
cache:
1010
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
1111
required: true

find-exact-python-version.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ set -euo pipefail
55
specified_version="$1"
66
specified_version_file="$2"
77

8+
desired_python_version="${specified_version}"
9+
if [ -f "${specified_version_file}" ]; then
10+
desired_python_version=$(cat "${specified_version_file}")
11+
fi
12+
813
# This versions map should be kept in sync with
914
# - https://www.python.org/downloads/
1015
# - https://devguide.python.org/versions/
11-
case "${specified_version}" in
16+
case "${desired_python_version}" in
1217
"3")
1318
echo "3.12.0"
1419
;;
@@ -28,6 +33,6 @@ case "${specified_version}" in
2833
echo "3.8.18"
2934
;;
3035
*)
31-
echo "${specified_version}"
36+
echo "${desired_python_version}"
3237
;;
3338
esac

0 commit comments

Comments
 (0)