|
1 | | -name: Validate Versions |
| 1 | +name: Version Check |
| 2 | + |
2 | 3 | on: |
3 | | - workflow_call: |
4 | | - inputs: |
5 | | - python-version: |
6 | | - required: true |
7 | | - type: string |
8 | | - matplotlib-version: |
9 | | - required: true |
10 | | - type: string |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
11 | 9 |
|
12 | 10 | jobs: |
13 | | - validate-versions: |
| 11 | + check-versions: |
14 | 12 | runs-on: ubuntu-latest |
| 13 | + |
15 | 14 | steps: |
16 | | - - name: Install tools |
17 | | - run: | |
18 | | - python3 -m pip install --upgrade pip |
19 | | - pip install requests packaging |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
20 | 17 |
|
21 | | - - name: Validate Python version |
22 | | - run: | |
23 | | - PY_VERSION="${{ inputs.python-version }}" |
24 | | - echo "Checking Python version: $PY_VERSION" |
| 18 | + - name: Install yq for toml parsing |
| 19 | + run: pip install yq |
25 | 20 |
|
26 | | - curl -s https://endoflife.date/api/python.json > python_eol.json |
| 21 | + - name: Read Python versions from pyproject.toml |
| 22 | + id: versions |
| 23 | + run: | |
| 24 | + PYTHON_VERSION=$(tomlq -r .tool.poetry.dependencies.python < pyproject.toml | tr -d '"') |
| 25 | + MATPLOTLIB_VERSION=$(tomlq -r .tool.poetry.dependencies.matplotlib < pyproject.toml | tr -d '"') |
27 | 26 |
|
28 | | - SUPPORTED=$(python3 - <<'PYCODE' |
29 | | -import json |
30 | | -from datetime import date |
31 | | -data = json.load(open("python_eol.json")) |
32 | | -today = date.today() |
33 | | -supported = [d["cycle"] for d in data if d.get("eol") in (False, None) or date.fromisoformat(str(d["eol"])) >= today] |
34 | | -print(",".join(supported)) |
35 | | -PYCODE |
36 | | -) |
37 | | - echo "Supported Python versions: $SUPPORTED" |
| 27 | + echo "python_version=$PYTHON_VERSION" >> $GITHUB_OUTPUT |
| 28 | + echo "matplotlib_version=$MATPLOTLIB_VERSION" >> $GITHUB_OUTPUT |
38 | 29 |
|
39 | | - if ! echo "$SUPPORTED" | grep -qw "$PY_VERSION"; then |
40 | | - echo "❌ Python $PY_VERSION is EOL!" |
41 | | - exit 1 |
42 | | - else |
43 | | - echo "✅ Python $PY_VERSION is supported." |
44 | | - fi |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ steps.versions.outputs.python_version }} |
0 commit comments