|
| 1 | +#!/bin/bash |
| 2 | +# bump_min_ha_version.sh |
| 3 | +# Usage: ./bump_min_ha_version.sh <ha_version> <pytest_homeassistant_version> |
| 4 | +# Example: ./bump_min_ha_version.sh 2025.3.0 0.13.215 |
| 5 | + |
| 6 | + |
| 7 | +set -e |
| 8 | + |
| 9 | +# Determine the directory where the script is located |
| 10 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 11 | + |
| 12 | +if [ $# -ne 2 ]; then |
| 13 | + echo "Usage: $0 <ha_version> <pytest_homeassistant_version>" |
| 14 | + |
| 15 | + # Get the previous version from hacs.json |
| 16 | + CURRENT_HA_VERSION=$(grep -oP '"homeassistant":\s*"\K[0-9.]+' "$SCRIPT_DIR/hacs.json" | head -n1) |
| 17 | + echo "Current minimum Home Assistant version is: $CURRENT_HA_VERSION" |
| 18 | + |
| 19 | + # Get current pytest-homeassistant-custom-component version |
| 20 | + CURRENT_PYTEST_HA_VERSION=$(grep -oP 'pytest-homeassistant-custom-component==\K[0-9.]+' "$SCRIPT_DIR/pyproject.toml" | head -n1) |
| 21 | + echo "Current pytest-homeassistant-custom-component version is: $CURRENT_PYTEST_HA_VERSION" |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +NEW_VERSION="$1" |
| 26 | +PYTEST_HA_VERSION="$2" |
| 27 | + |
| 28 | +# Update homeassistant version in hacs.json |
| 29 | +sed -i "s/\"homeassistant\": \"[0-9.]*\"/\"homeassistant\": \"$NEW_VERSION\"/" "$SCRIPT_DIR/hacs.json" |
| 30 | + |
| 31 | +# Update homeassistant-stubs in pyproject.toml |
| 32 | +sed -i "s/homeassistant-stubs==[0-9.]*/homeassistant-stubs==$NEW_VERSION/" "$SCRIPT_DIR/pyproject.toml" |
| 33 | + |
| 34 | +# Update pytest-homeassistant-custom-component |
| 35 | +sed -i "s/pytest-homeassistant-custom-component==[0-9.]*/pytest-homeassistant-custom-component==$PYTEST_HA_VERSION/" "$SCRIPT_DIR/pyproject.toml" |
| 36 | + |
| 37 | +# Update minimum HA version in README.md |
| 38 | +sed -i "s/Minimum required Home Assistant version is: [0-9.]*/Minimum required Home Assistant version is: $NEW_VERSION/" "$SCRIPT_DIR/README.md" |
| 39 | + |
| 40 | +echo "Minimum HA version bumped to $NEW_VERSION in hacs.json, pyproject.toml, and README.md files." |
| 41 | +echo "pytest-homeassistant-custom-component updated to $PYTEST_HA_VERSION." |
0 commit comments