3636 - name : Check if update is needed
3737 id : check_update
3838 run : |
39- current=$(jq -r '.requirements[0]' custom_components/victron_mqtt/manifest.json | cut -d'=' -f3)
39+ # Compare against the vendored lib version by checking the wheel we'd download
4040 latest="${{ steps.get_release.outputs.latest_version }}"
41+ # Check if the lib/ directory already has this version by looking at a marker file
42+ if [ -f "custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version" ]; then
43+ current=$(cat custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version)
44+ else
45+ current="unknown"
46+ fi
4147 echo "Current: $current, Latest: $latest"
4248 if [ "$current" = "$latest" ]; then
4349 echo "No update needed."
@@ -47,20 +53,33 @@ jobs:
4753 echo "update_needed=true" >> $GITHUB_OUTPUT
4854 fi
4955
50- - name : Update dependency pins with new version
56+ - name : Download and vendor victron_mqtt library
5157 if : steps.check_update.outputs.update_needed == 'true'
5258 run : |
5359 set -e
5460 latest="${{ steps.get_release.outputs.latest_version }}"
5561
56- # Pin integration runtime dependency.
57- jq \
58- --arg v "$latest" \
59- '.requirements[0] = "victron_mqtt=="+$v' \
60- custom_components/victron_mqtt/manifest.json > manifest.tmp && mv manifest.tmp custom_components/victron_mqtt/manifest.json
62+ # Download the wheel from PyPI
63+ pip download "victron_mqtt==$latest" --no-deps -d /tmp/victron_wheel
64+
65+ # Extract the wheel (it's a zip file)
66+ wheel_file=$(ls /tmp/victron_wheel/victron_mqtt-*.whl)
67+ unzip -o "$wheel_file" "victron_mqtt/*" -d /tmp/victron_extracted
68+
69+ # Replace the vendored lib/ directory
70+ rm -rf custom_components/victron_mqtt/_vendor/victron_mqtt
71+ cp -r /tmp/victron_extracted/victron_mqtt custom_components/victron_mqtt/_vendor/victron_mqtt
72+
73+ # Remove __pycache__, py.typed, and utils/ (not needed in integration context)
74+ find custom_components/victron_mqtt/_vendor/victron_mqtt -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
75+ rm -f custom_components/victron_mqtt/_vendor/victron_mqtt/py.typed
76+ rm -rf custom_components/victron_mqtt/_vendor/victron_mqtt/utils
77+
78+ # Write version marker
79+ echo "$latest" > custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version
6180
62- # Pin local/dev test dependency.
63- sed -i -E "s|^victron_mqtt(==[0-9][0-9A-Za-z.\-]*)?$|victron_mqtt==$latest|" requirements.txt
81+ # Cleanup
82+ rm -rf /tmp/victron_wheel /tmp/victron_extracted
6483
6584 - name : Download victron_mqtt release package from PyPI
6685 if : steps.check_update.outputs.update_needed == 'true'
0 commit comments