Skip to content

Commit cd9ac1f

Browse files
committed
Try to fix Python action
1 parent 3b9f30c commit cd9ac1f

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

.github/workflows/python-latest.yml

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

99
jobs:
10-
# Define the job to run before your matrix job
10+
# --------------------------------------------------------
11+
# Collect available Python versions
12+
# --------------------------------------------------------
1113
get-python-versions:
1214
runs-on: ubuntu-latest
1315
outputs:
14-
python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }}
16+
python-matrix: ${{ steps.trim.outputs.matrix }}
1517
steps:
16-
- uses: snok/latest-python-versions@v1
17-
id: get-python-versions-action
18-
with:
19-
min-version: '3.12'
18+
- uses: snok/latest-python-versions@v1
19+
id: get-python-versions-action
20+
with:
21+
min-version: '3.12'
22+
23+
# 👇 keep only major.minor and remove duplicates
24+
- name: Keep only major.minor
25+
id: trim
26+
shell: bash
27+
run: |
28+
versions='${{ steps.get-python-versions-action.outputs.latest-python-versions }}'
29+
# → ["3.13.5","3.12.11", ...]
30+
matrix=$(echo "$versions" \
31+
| jq -c 'map(split(".")[:2] | join(".")) | unique')
32+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
2033
34+
# --------------------------------------------------------
35+
# Use the trimmed versions list in matrix
36+
# --------------------------------------------------------
2137
test:
2238
needs: [get-python-versions]
2339
runs-on: ${{ matrix.operating-system }}
2440
strategy:
2541
matrix:
2642
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-
43+
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}
3044
continue-on-error: true
3145

3246
steps:

0 commit comments

Comments
 (0)