-
Notifications
You must be signed in to change notification settings - Fork 5
56 lines (53 loc) · 2.14 KB
/
check-versions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Check versions
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- created
jobs:
check-versions:
name: Check-versions
strategy:
matrix:
python-version: [3.11]
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: ⚙️ Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.5.1
- name: ⚙️ Install dependencies
run: poetry install
- name: 🚀 Check Manifest.json
run: |
current_version=$(poetry version | awk '{print $2}')
manifest_version=$(jq -r '.version' custom_components/qss/manifest.json)
if [[ "$current_version" != "$manifest_version" ]]; then
echo "Error: Version mismatch between pyproject.toml ($current_version) and manifest.json ($manifest_version)"
exit 1
fi
current_dependencies=$(poetry show --only main --format=json | jq -r '.default.dependencies')
manifest_dependencies=$(jq -r '.requirements[]' custom_components/qss/manifest.json)
for dependency in $manifest_dependencies; do
poetry_version_spec=$(poetry show --only main --format=json "$dependency" | jq -r '.version')
normalized_poetry_version_spec=$(awk '{ sub(/[\^~>=]/, "", $0); print }' <<<"$poetry_version_spec")
normalized_manifest_dependency=$(sed 's/=.*,/>=/' <<<"$dependency")
if ! poetry show --only main --format=json "$normalized_manifest_dependency" &>/dev/null; then
echo "Error: Missing dependency $dependency in pyproject.toml"
exit 1
elif ! [[ "$normalized_manifest_dependency" =~ $normalized_poetry_version_spec ]]; then
echo "Error: Version mismatch between pyproject.toml ($poetry_version_spec) and manifest.json ($dependency)"
exit 1
fi
done