Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
71 lines (61 loc) · 2.88 KB
/
Copy pathaction.yml
File metadata and controls
71 lines (61 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: 'Setup python amazon linux'
description: 'setup-python action for amazon linux self hosted runners'
inputs:
python-version:
description: 'Version of python to be installed. Reads from .python-version if unset.'
python-version-file:
description: 'Version of python to be installed'
default: '.python-version'
cache:
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
required: true
default: 'true'
runs:
using: "composite"
steps:
- name: Ensure dependencies of python are installed
shell: bash
run: |
${GITHUB_ACTION_PATH}/install-system-dependencies.sh
- name: Find exact python version
id: find-exact-python-version
shell: bash
run: |
exact_python_version=$(${GITHUB_ACTION_PATH}/find-exact-python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
echo "exact_python_version=${exact_python_version}" >> $GITHUB_OUTPUT
- name: Set installation directory
id: set-installation-directory
shell: bash
run: |
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
- name: Cache
id: cache-python
uses: actions/cache@v3
if: inputs.cache == 'true'
with:
path: ${{ steps.set-installation-directory.outputs.installation_directory }}
key: python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }}
- id: setup-python
shell: bash
if: inputs.cache == 'false' || (inputs.cache == 'true' && steps.cache-python.outputs.cache-hit != 'true')
run: |
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
# Using a separate tmp directory instead of /tmp because in some OS images set a noexec option for the mount
# this is a better way compared to changing the mount options of /tmp
tmp_directory="${HOME}/.setup-python-amazon-linux/tmp"
${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}" "${tmp_directory}"
- name: Add python to PATH
shell: bash
run: |
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
echo "${installation_directory}/bin" >> "${GITHUB_PATH}"
echo "The following python binaries are now available in the PATH"
ls "${installation_directory}/bin"
echo "Linking python libraries..."
ls "${installation_directory}/lib"
sudo ldconfig "${installation_directory}/lib"
branding:
icon: 'code'
color: 'yellow'