fix(release): wire Hermes into version bumps

Register the Hermes YAML manifest alongside the existing JSON manifests. Route manifest reads and writes by extension through jq or Mike Farah yq v4, with field names and values passed as data.

Preflight every present manifest before the mutating bump loop so a deterministic YAML read failure cannot leave earlier JSON manifests partially updated. Cover check, audit, bump, registry wiring, and byte-for-byte no-partial-write behavior with one focused fixture test.
This commit is contained in:
Drew Ritter
2026-08-06 14:47:14 -07:00
committed by Jesse Vincent
parent 707b155a38
commit 5f8f500b1d
3 changed files with 143 additions and 4 deletions
+66 -4
View File
@@ -40,12 +40,72 @@ write_json_field() {
jq "$jq_path = \"$value\"" "$file" > "$tmp" && mv "$tmp" "$file"
}
require_tool() {
command -v "$1" >/dev/null 2>&1 || {
echo "error: required tool '$1' is not on PATH" >&2
return 1
}
}
read_yaml_field() {
local file="$1" field="$2"
require_tool yq || return 1
FIELD="$field" yq -er '.[strenv(FIELD)] | select(tag == "!!str")' "$file"
}
write_yaml_field() {
local file="$1" field="$2" value="$3"
FIELD="$field" VALUE="$value" \
yq -i '.[strenv(FIELD)] = strenv(VALUE)' "$file"
}
read_manifest_field() {
local file="$1"
case "$file" in
*.json) read_json_field "$@" ;;
*.yaml) read_yaml_field "$@" ;;
*)
echo "error: unsupported manifest format: $file" >&2
return 1
;;
esac
}
write_manifest_field() {
local file="$1"
case "$file" in
*.json) write_json_field "$@" ;;
*.yaml) write_yaml_field "$@" ;;
*)
echo "error: unsupported manifest format: $file" >&2
return 1
;;
esac
}
# Read the list of declared files from config.
# Outputs lines of "path<TAB>field"
declared_files() {
jq -r '.files[] | "\(.path)\t\(.field)"' "$CONFIG"
}
preflight_manifests() {
local path field fullpath
require_tool jq || return 1
while IFS=$'\t' read -r path field; do
fullpath="$REPO_ROOT/$path"
[[ -f "$fullpath" ]] || continue
if ! read_manifest_field "$fullpath" "$field" >/dev/null; then
echo "error: cannot read declared manifest: $path ($field)" >&2
return 1
fi
done < <(declared_files)
}
# Read the audit exclude patterns from config.
audit_excludes() {
jq -r '.audit.exclude[]' "$CONFIG" 2>/dev/null
@@ -68,7 +128,7 @@ cmd_check() {
continue
fi
local ver
ver=$(read_json_field "$fullpath" "$field")
ver=$(read_manifest_field "$fullpath" "$field")
printf " %-45s %s\n" "$path ($field)" "$ver"
versions+=("$ver")
done < <(declared_files)
@@ -101,7 +161,7 @@ cmd_audit() {
current_version=$(
while IFS=$'\t' read -r path field; do
local fullpath="$REPO_ROOT/$path"
[[ -f "$fullpath" ]] && read_json_field "$fullpath" "$field"
[[ -f "$fullpath" ]] && read_manifest_field "$fullpath" "$field"
done < <(declared_files) | sort | uniq -c | sort -rn | head -1 | awk '{print $2}'
)
@@ -172,6 +232,8 @@ cmd_bump() {
exit 1
fi
preflight_manifests
echo "Bumping all declared files to $new_version..."
echo ""
@@ -182,8 +244,8 @@ cmd_bump() {
continue
fi
local old_ver
old_ver=$(read_json_field "$fullpath" "$field")
write_json_field "$fullpath" "$field" "$new_version"
old_ver=$(read_manifest_field "$fullpath" "$field")
write_manifest_field "$fullpath" "$field" "$new_version"
printf " %-45s %s -> %s\n" "$path ($field)" "$old_ver" "$new_version"
done < <(declared_files)