Skip to content

Commit 9c477bc

Browse files
committed
version 2
1 parent 26bed39 commit 9c477bc

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed
Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
1-
name: Validate Versions
1+
name: Version Check
2+
23
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:
119

1210
jobs:
13-
validate-versions:
11+
check-versions:
1412
runs-on: ubuntu-latest
13+
1514
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
2017

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
2520

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 '"')
2726
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
3829
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

Comments
 (0)