mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
150 lines
4.5 KiB
Bash
Executable File
150 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
FREEZE_OVERRIDE="${DOC_RELEASE_FREEZE_OVERRIDE:-false}"
|
|
FREEZE_REASON="${DOC_RELEASE_FREEZE_REASON:-}"
|
|
|
|
errors=0
|
|
|
|
is_truthy() {
|
|
local value
|
|
value="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')"
|
|
case "$value" in
|
|
1|true|yes|y|on)
|
|
return 0
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
run_check() {
|
|
local name="$1"
|
|
shift
|
|
|
|
echo "=== $name ==="
|
|
if "$@"; then
|
|
echo "PASS: $name"
|
|
else
|
|
echo "FAIL: $name"
|
|
errors=$((errors + 1))
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
validate_message_freeze() {
|
|
# Release notes are now generated by scripts/extract-release-notes.sh
|
|
# from the repository-root CHANGELOG.md. Validate that the script and
|
|
# changelog contract are aligned.
|
|
local release_notes_script="$REPO_ROOT/scripts/extract-release-notes.sh"
|
|
local changelog="$REPO_ROOT/CHANGELOG.md"
|
|
local marketplace_changelog="$REPO_ROOT/docs/CHANGELOG.md"
|
|
local goreleaser_file="$REPO_ROOT/.goreleaser.yml"
|
|
local plugin_manifest="$REPO_ROOT/.claude-plugin/plugin.json"
|
|
local mismatches=0
|
|
local release_version=""
|
|
|
|
if is_truthy "$FREEZE_OVERRIDE"; then
|
|
if [[ -z "$FREEZE_REASON" ]]; then
|
|
echo "ERROR: DOC_RELEASE_FREEZE_OVERRIDE is set, but DOC_RELEASE_FREEZE_REASON is empty"
|
|
return 1
|
|
fi
|
|
echo "OVERRIDE: message freeze check bypassed"
|
|
echo "Reason: $FREEZE_REASON"
|
|
return 0
|
|
fi
|
|
|
|
if [[ ! -f "$release_notes_script" ]]; then
|
|
echo "MISMATCH: scripts/extract-release-notes.sh not found"
|
|
mismatches=$((mismatches + 1))
|
|
elif [[ ! -x "$release_notes_script" ]]; then
|
|
echo "MISMATCH: scripts/extract-release-notes.sh is not executable"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
|
|
if [[ ! -f "$changelog" ]]; then
|
|
echo "MISMATCH: CHANGELOG.md not found"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
|
|
if [[ ! -f "$marketplace_changelog" ]]; then
|
|
echo "MISMATCH: docs/CHANGELOG.md not found"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
|
|
if [[ ! -f "$goreleaser_file" ]]; then
|
|
echo "MISMATCH: .goreleaser.yml not found"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
|
|
if [[ ! -f "$plugin_manifest" ]]; then
|
|
echo "MISMATCH: .claude-plugin/plugin.json not found"
|
|
mismatches=$((mismatches + 1))
|
|
elif command -v jq >/dev/null 2>&1; then
|
|
release_version="$(jq -r '.version // empty' "$plugin_manifest")"
|
|
if [[ -z "$release_version" ]]; then
|
|
echo "MISMATCH: .claude-plugin/plugin.json missing version"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
fi
|
|
|
|
# Verify release notes script contains expected elements
|
|
if [[ -f "$release_notes_script" ]]; then
|
|
if ! grep -Fq 'brew upgrade agentops' "$release_notes_script"; then
|
|
echo "MISMATCH: release notes script missing brew upgrade header"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
if ! grep -Fq 'checksums' "$release_notes_script"; then
|
|
echo "MISMATCH: release notes script missing checksums link"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
if ! grep -Fq 'Full Changelog' "$release_notes_script"; then
|
|
echo "MISMATCH: release notes script missing full changelog footer"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
fi
|
|
|
|
# Verify workflow passes --release-notes to GoReleaser
|
|
local workflow="$REPO_ROOT/.github/workflows/release.yml"
|
|
if [[ -f "$workflow" ]]; then
|
|
if ! grep -Fq 'release-notes' "$workflow"; then
|
|
echo "MISMATCH: release.yml not passing --release-notes to GoReleaser"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
fi
|
|
|
|
if [[ -n "$release_version" ]]; then
|
|
if ! grep -Fq "## [$release_version]" "$changelog"; then
|
|
echo "MISMATCH: root CHANGELOG.md missing release entry for $release_version"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
if ! grep -Fq "## [$release_version]" "$marketplace_changelog"; then
|
|
echo "MISMATCH: docs/CHANGELOG.md missing release entry for $release_version"
|
|
mismatches=$((mismatches + 1))
|
|
fi
|
|
fi
|
|
|
|
if [[ "$mismatches" -gt 0 ]]; then
|
|
echo "To intentionally bypass in CI, set:"
|
|
echo " DOC_RELEASE_FREEZE_OVERRIDE=true"
|
|
echo " DOC_RELEASE_FREEZE_REASON='<why this change is required>'"
|
|
return 1
|
|
fi
|
|
|
|
echo "PASS: release message freeze intact"
|
|
return 0
|
|
}
|
|
|
|
run_check "Link validation" bash "$REPO_ROOT/tests/docs/validate-links.sh"
|
|
run_check "Skill count validation" bash "$REPO_ROOT/tests/docs/validate-skill-count.sh"
|
|
run_check "Release message freeze validation" validate_message_freeze
|
|
|
|
if [[ "$errors" -gt 0 ]]; then
|
|
echo "FAIL: doc-release gate failed ($errors check(s) failed)"
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: doc-release gate succeeded"
|