#!/usr/bin/env bash # Fail the commit if gateway-plugin/plugin.yaml's `version:` field drifts # from the repo-root VERSION file (the single source of truth). # # Why: `hermes plugins install #gateway-plugin` ships ONLY the # gateway-plugin/ subdirectory into ~/.hermes/plugins/iris, so in production # the gateway advertises the version from plugin.yaml (see # gateway-plugin/version.py). If the two drift, the app shows a false # "versions differ" warning. set -euo pipefail repo_root="$(git rev-parse --show-toplevel)" version_file="$repo_root/VERSION" plugin_yaml="$repo_root/gateway-plugin/plugin.yaml" [ -f "$version_file" ] || { echo "check_version_sync: missing $version_file" >&2 exit 1 } [ -f "$plugin_yaml" ] || { echo "check_version_sync: missing $plugin_yaml" >&2 exit 1 } root_version="$(tr -d '[:space:]' <"$version_file")" # Mirrors gateway-plugin/version.py's _VERSION_RE: optional single OR double # quote, at least one captured character. yaml_version="$(sed -n "s/^version:[[:space:]]*[\"']\{0,1\}\([^\"'[:space:]]\{1,\}\).*/\1/p" "$plugin_yaml" | head -n1)" if [ -z "$yaml_version" ]; then echo "check_version_sync: no top-level 'version:' field in gateway-plugin/plugin.yaml" >&2 exit 1 fi if [ "$root_version" != "$yaml_version" ]; then echo "check_version_sync: version drift" >&2 echo " VERSION (repo root) = $root_version" >&2 echo " gateway-plugin/plugin.yaml = $yaml_version" >&2 echo "Bump both to the same value (VERSION is the source of truth)." >&2 exit 1 fi