Skip to content

Commit bebd65e

Browse files
Merge pull request #3 from SmartMonkey-git/rr/ci/seperate-python-installation
CI/CD: Refactor python installation from pyproject.toml into own action
2 parents 902a119 + 7661e51 commit bebd65e

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Install python from pyproject.toml
2+
description: 'Installs Python from the version found in the pyproject.toml'
3+
4+
inputs:
5+
pyproject-file-path:
6+
required: False
7+
description: "Path to the pyproject.toml including filename"
8+
default: "./pyproject.toml"
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Get project version with yq
14+
id: get_python_version
15+
uses: mikefarah/yq@v4.46.1
16+
with:
17+
cmd: yq '.project.requires-python' ${{ inputs.pyproject-file-path }}
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5.6.0
21+
with:
22+
python-version: ${{ steps.get_python_version.outputs.result }}

.github/actions/setup_env/action.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@ description: 'Sets up and caches a python env. Will only install dependencies if
44
runs:
55
using: composite
66
steps:
7-
- name: Get project version with yq
8-
id: get_python_version
9-
uses: mikefarah/yq@v4.46.1
10-
with:
11-
cmd: yq '.project.requires-python' pyproject.toml
12-
13-
- name: Set up Python
14-
uses: actions/setup-python@v5.6.0
15-
with:
16-
python-version: ${{ steps.get_python_version.outputs.result }}
7+
- name: Setup Python from pyproject.toml
8+
uses: ./.github/actions/python_from_pyproject
179

1810
- name: Cache Env
1911
uses: actions/cache@v4.2.3

.github/workflows/cd.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ jobs:
1818
persist-credentials: false
1919
fetch-depth: 0
2020

21-
- name: Get project version with yq
22-
id: get_python_version
23-
uses: mikefarah/yq@v4.46.1
24-
with:
25-
cmd: yq '.project.requires-python' pyproject.toml
26-
27-
- name: Initialize Python
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: ${{ steps.get_python_version.outputs.result }}
21+
- name: Setup Python from pyproject.toml
22+
uses: ./.github/actions/python_from_pyproject
3123

3224
- name: Install build
3325
run: >-

0 commit comments

Comments
 (0)