-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
75 lines (64 loc) · 2.97 KB
/
action.yml
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
72
73
74
75
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: >
[Deprecated] Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
Current implementation uses uv which pulls in pre-compiled binaries of python thereby eliminating the
need to cache compiled python artifacts.
default: 'true'
runs:
using: "composite"
steps:
- name: Ensure system dependencies are installed
shell: bash
run: |
sudo yum install -y tar gzip which
- name: Install uv
shell: bash
run: |
installation_directory="${HOME}/.setup-python-amazon-linux/uv"
echo "Installing uv.. installation_directory=${installation_directory}"
uv_version="0.5.11"
curl -LsSf "https://github.com/astral-sh/uv/releases/download/${uv_version}/uv-installer.sh" | UV_UNMANAGED_INSTALL="${installation_directory}" bash --login
echo "${installation_directory}" >> "${GITHUB_PATH}"
- name: Find desired python version
id: find-desired-python-version
shell: bash
run: |
desired_python_version=$(${GITHUB_ACTION_PATH}/find-desired-python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
echo "desired_python_version=${desired_python_version}" | tee -a "${GITHUB_OUTPUT}"
- name: Set installation directory
id: set-installation-directory
shell: bash
run: |
desired_python_version="${{ steps.find-desired-python-version.outputs.desired_python_version }}"
echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${desired_python_version}" | tee -a "${GITHUB_OUTPUT}"
- id: setup-python
shell: bash
run: |
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
desired_python_version="${{ steps.find-desired-python-version.outputs.desired_python_version }}"
uv venv --python "${desired_python_version}" "${installation_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"
- name: Install pip
shell: bash
run: |
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
python -m ensurepip --upgrade
ln -sf "${installation_directory}/bin/pip3" "${installation_directory}/bin/pip"
pip install --upgrade pip
branding:
icon: 'code'
color: 'yellow'