Skip to content

Commit 1f69d7c

Browse files
author
FirstUnicorn
committed
ci: auto-detect Poetry version from lock file in dependency validation
1 parent b7acd38 commit 1f69d7c

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/validate-dependencies.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,25 @@ jobs:
1616
with:
1717
python-version: '3.10'
1818

19+
- name: Detect Poetry version from lock file
20+
id: poetry-version
21+
run: |
22+
version="$(python - <<'PY'
23+
import re
24+
from pathlib import Path
25+
26+
first_line = Path('poetry.lock').read_text(encoding='utf-8').splitlines()[0]
27+
match = re.search(r'Poetry ([0-9]+(?:\.[0-9]+)+)', first_line)
28+
if not match:
29+
raise SystemExit('Could not determine Poetry version from poetry.lock')
30+
print(match.group(1))
31+
PY
32+
)"
33+
echo "version=$version" >> "$GITHUB_OUTPUT"
34+
1935
- name: Install Poetry and dependencies
2036
run: |
21-
pip install poetry==2.3.3 tomli
37+
pip install "poetry==${{ steps.poetry-version.outputs.version }}" tomli
2238
2339
# Option 1: Poetry lock file validation
2440
- name: Check pyproject.toml validity

0 commit comments

Comments
 (0)