diff --git a/manifest.json b/manifest.json index a74ff9134..fecab03d9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,14 @@ { - "versions": ["v1.36", "v1.35", "v1.34", "v1.33", "v1.32", "v1.31", "v1.30"], + "versions": [ + "v1.37", + "v1.36", + "v1.35", + "v1.34", + "v1.33", + "v1.32", + "v1.31", + "v1.30" + ], "routes": [ { "path": "./index.md", diff --git a/package.json b/package.json index 75c944fd1..a44b6b8d3 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,9 @@ "*.md": [ "markdownlint --config .markdownlint.jsonc --rules .markdownlint-rules --fix", "prettier --write" + ], + "manifest.json": [ + "./scripts/validate-manifest.sh" ] }, "dependencies": { diff --git a/scripts/validate-manifest.sh b/scripts/validate-manifest.sh new file mode 100755 index 000000000..b882011b0 --- /dev/null +++ b/scripts/validate-manifest.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# validate-manifest.sh [path/to/manifest.json] +# +# Dependencies: bash>=4.x jq tr sort uniq +# +# Description: Ensures consistency of versions specified in manifest.json. + +set -euo pipefail + +if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then + echo "This script requires at least bash version 4." + exit 1 +fi + +if ! command -v jq > /dev/null; then + echo "This script requires jq to be available." + exit 1 +fi + +GIT_ROOT=$(cd "$(dirname "$0")" && git rev-parse --show-toplevel) +MANIFEST_JSON_PATH=${1:-"${GIT_ROOT}/manifest.json"} + +declare -a MANIFEST_VERSIONS +declare -a ROUTE_VERSIONS + +# Read the versions array in manifest.json +readarray -t MANIFEST_VERSIONS < <(jq -r ' + .versions[] + | capture("(?[0-9]+\\.[0-9]+)") + | .v' < "${MANIFEST_JSON_PATH}") + +# Read all the child paths of changelog/index.md and extract major.minor version +readarray -t ROUTE_VERSIONS < <(jq -r ' + .routes[] + | select(.path == "./changelog/index.md") + | .children[] + | .path | + capture("(?[0-9]+\\.[0-9]+)") + | .v' < "${MANIFEST_JSON_PATH}") + +# Compare the two +DIFF=$(echo "${MANIFEST_VERSIONS[@]}" "${ROUTE_VERSIONS[@]}" | tr ' ' '\n' | sort | uniq -u) +if [[ -n $DIFF ]]; then + echo "manifest.json: missing version for changelog(s): ${DIFF}" + exit 1 +fi + +exit 0 \ No newline at end of file