Skip to content

Commit 17f1fe6

Browse files
committed
Fixing Python versions in GH action
1 parent 3b9f30c commit 17f1fe6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/python-latest.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,36 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
# Define the job to run before your matrix job
10+
# Collect available Python versions
1111
get-python-versions:
1212
runs-on: ubuntu-latest
1313
outputs:
14-
python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }}
14+
python-matrix: ${{ steps.trim.outputs.matrix }}
1515
steps:
1616
- uses: snok/latest-python-versions@v1
1717
id: get-python-versions-action
1818
with:
1919
min-version: '3.12'
2020

21+
# keep only major.minor and remove duplicates
22+
- name: Keep only major.minor
23+
id: trim
24+
shell: bash
25+
run: |
26+
versions='${{ steps.get-python-versions-action.outputs.latest-python-versions }}'
27+
# → ["3.13.5","3.12.11", ...]
28+
matrix=$(echo "$versions" \
29+
| jq -c 'map(split(".")[:2] | join(".")) | unique')
30+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
31+
32+
# Use the trimmed versions list in matrix
2133
test:
2234
needs: [get-python-versions]
2335
runs-on: ${{ matrix.operating-system }}
2436
strategy:
2537
matrix:
2638
operating-system: [ ubuntu-latest, windows-latest, macOS-latest ]
27-
# python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}
28-
python-version: [3.13.5, 3.12.10]
29-
39+
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}
3040
continue-on-error: true
3141

3242
steps:

0 commit comments

Comments
 (0)