@@ -11,19 +11,30 @@ runs:
11
11
- name : Checkout code
12
12
uses : actions/checkout@v4
13
13
14
- - name : Install .python-version and ${{ inputs.python-version }}
15
- uses : " gabrielfalcao/pyenv-action@v18"
16
- with :
17
- default : 3.7.17
18
- versions : ${{ inputs.python-version }}
14
+ - name : Install pyenv from source
15
+ run : |
16
+ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
17
+ echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
18
+ echo "$HOME/.pyenv/bin" >> $GITHUB_PATH
19
+ shell : bash
19
20
20
- - name : Switch to .python-version
21
+ - name : Install Python ${{ inputs .python-version }} via pyenv
21
22
run : |
22
- pyenv local "$(cat .python-version)"
23
- if python -V | grep -q "$(cat .python-version)"; then
24
- echo "Python version is '$(python -V)'"
25
- else
26
- echo "Python version is '$(python -V)', but should be '$(cat .python-version)'. Exiting workflow."
23
+ export PYENV_ROOT="$HOME/.pyenv"
24
+ export PATH="$PYENV_ROOT/bin:$PATH"
25
+ eval "$(pyenv init --path)"
26
+ pyenv install -s ${{ inputs.python-version }}
27
+ pyenv global ${{ inputs.python-version }}
28
+ echo "${{ inputs.python-version }}" > .python-version
29
+ shell : bash
30
+
31
+ - name : Verify installed Python version
32
+ run : |
33
+ ACTUAL=$(python -V)
34
+ EXPECTED=${{ inputs.python-version }}
35
+ echo "Python version installed: $ACTUAL"
36
+ if ! python -V | grep -q "$EXPECTED"; then
37
+ echo "Python version is not correct. Exiting."
27
38
exit 1
28
39
fi
29
40
shell : bash
0 commit comments