hass.tibber_prices/scripts/release/check-if-released
Julian Pawlowski a90fef6f2d refactor(scripts): reorganize and standardize development scripts
Major restructuring of the scripts/ directory with consistent output
formatting, improved organization, and stricter error handling.

Breaking Changes:
- Updated development environment to Home Assistant 2025.7+
  - Removed Python 3.12 compatibility (HA 2025.7+ requires Python 3.13)
  - Updated all HA core requirements from 2025.7 requirement files
  - Added new dependencies: python-multipart, uv (for faster package management)
  - Updated GitHub Actions workflows to use Python 3.13

Changes:
- Created centralized output library (scripts/.lib/output.sh)
  - Unified color codes and Unicode symbols
  - Consistent formatting functions (log_header, log_success, log_error, etc.)
  - Support for embedded formatting codes (${BOLD}, ${GREEN}, etc.)

- Reorganized into logical subdirectories:
  - scripts/setup/ - Setup and maintenance scripts
    - bootstrap: Install/update dependencies (used in CI/CD)
    - setup: Full DevContainer setup (pyright, copilot, HACS)
    - reset: Reset config/ directory to fresh state (NEW)
    - sync-hacs: Sync HACS integrations
  - scripts/release/ - Release management scripts
    - prepare: Version bump and tagging
    - suggest-version: Semantic version suggestion
    - generate-notes: Release notes generation
    - check-if-released: Check release status
    - hassfest: Local integration validation

- Updated all scripts with:
  - set -euo pipefail for stricter error handling
  - Consistent SCRIPT_DIR pattern for reliable sourcing
  - Professional output with colors and emojis
  - Unified styling across all 17 scripts

- Removed redundant scripts:
  - scripts/update (was just wrapper around bootstrap)
  - scripts/json_schemas/ (moved to schemas/json/)

- Enhanced clean script:
  - Improved artifact cleanup
  - Better handling of accidental package installations
  - Hints for reset and deep clean options

- New reset script features:
  - Standard mode: Keep configuration.yaml
  - Full mode (--full): Reset configuration.yaml from git
  - Automatic re-setup after reset

- Updated documentation:
  - AGENTS.md: Updated script references and workflow guidance
  - docs/development/: Updated all references to new script structure

Impact: Development environment now requires Python 3.13 and Home Assistant
2025.7+. Developers get consistent, professional script output with better
error handling and logical organization. Single source of truth for styling
makes future updates trivial.
2025-11-26 13:11:52 +00:00

89 lines
2.6 KiB
Bash
Executable file

#!/bin/bash
# script/check-if-released: Check if a commit has been released in any version tag
#
# Determines whether a specific commit is included in any released version tag.
# Useful for deciding if legacy migration code is needed for unreleased changes.
#
# Usage:
# ./scripts/release/check-if-released <commit-hash> [--details]
#
# Examples:
# ./scripts/release/check-if-released f4568be
# ./scripts/release/check-if-released HEAD~3 --details
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/../.."
# shellcheck source=scripts/.lib/output.sh
source "$SCRIPT_DIR/../.lib/output.sh"
# Check if commit hash provided
if [[ -z ${1:-} ]]; then
echo "Usage: $0 <commit-hash> [--details]"
echo ""
echo "Examples:"
echo " $0 f4568be"
echo " $0 HEAD~3 --details"
exit 1
fi
COMMIT="$1"
DETAILS="${2:-}"
# Validate commit exists
if ! git rev-parse --verify "$COMMIT" >/dev/null 2>&1; then
die "Commit '$COMMIT' not found"
fi
# Get full commit hash
FULL_HASH=$(git rev-parse "$COMMIT")
SHORT_HASH=$(git rev-parse --short "$COMMIT")
# Get commit info
COMMIT_SUBJECT=$(git log -1 --format="%s" "$COMMIT")
COMMIT_DATE=$(git log -1 --format="%ci" "$COMMIT")
echo "Checking commit: $SHORT_HASH"
echo "Subject: $COMMIT_SUBJECT"
echo "Date: $COMMIT_DATE"
echo ""
# Check if commit is in any version tag (v*.*.*)
TAGS=$(git tag --contains "$COMMIT" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || true)
if [[ -z $TAGS ]]; then
printf '%b✓ NOT RELEASED%b\n' "$GREEN" "$NC"
echo "This commit is not part of any version tag."
echo ""
printf '%b→ No legacy migration needed for code introduced in this commit%b\n' "$YELLOW" "$NC"
exit 0
else
printf '%b✗ ALREADY RELEASED%b\n' "$RED" "$NC"
echo "This commit is included in the following version tags:"
echo "$TAGS" | sed 's/^/ - /'
echo ""
printf '%b⚠ Breaking Change Decision:%b\n' "$YELLOW" "$NC"
echo " 1. If migration is SIMPLE (e.g., .lower(), key rename) → Add it"
echo " 2. If migration is COMPLEX → Document in release notes instead"
echo " 3. Home Assistant style: Prefer breaking changes over code complexity"
echo ""
if [[ $DETAILS == --details ]]; then
echo ""
echo "First release containing this commit:"
FIRST_TAG=$(echo "$TAGS" | head -1)
echo " Tag: $FIRST_TAG"
git log -1 --format=" Date: %ci" "$FIRST_TAG"
echo ""
echo "Latest release:"
LATEST_TAG=$(git tag -l 'v*.*.*' --sort=-version:refname | head -1)
echo " Tag: $LATEST_TAG"
git log -1 --format=" Date: %ci" "$LATEST_TAG"
fi
exit 1
fi