Skip to content

Commit c9b8095

Browse files
feat: inject anolis schemas into VitePress public dir at deploy time (S-1)
- schemas/anolis-version.json: pin file declaring which anolis release to fetch schemas from (currently v0.1.4) - scripts/inject-schemas.sh: downloads the 4 schema tarballs from the pinned anolis GitHub release, extracts each schema file, and writes them under docs/public/schemas/anolis/. VitePress serves docs/public/ verbatim, so schemas are available at the URIs: https://anolishq.github.io/schemas/anolis/runtime/runtime-config.schema.json https://anolishq.github.io/schemas/anolis/machine/machine-profile.schema.json https://anolishq.github.io/schemas/anolis/telemetry/telemetry-timeseries.schema.v1.json https://anolishq.github.io/schemas/anolis/http/runtime-http.openapi.v0.yaml - .github/workflows/deploy.yml: run inject-schemas.sh before pnpm build To update the published schema version: edit schemas/anolis-version.json and push to main. No secrets or cross-repo writes required.
1 parent 0bf9af2 commit c9b8095

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131

3232
- run: pnpm install --frozen-lockfile
3333

34+
- name: Inject anolis schemas
35+
run: bash scripts/inject-schemas.sh
36+
3437
- run: pnpm build
3538

3639
# Note: VitePress validates dead links at build time (ignoreDeadLinks: false).

schemas/anolis-version.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"anolis_version": "0.1.4"
3+
}

scripts/inject-schemas.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
# inject-schemas.sh — fetch canonical anolis schemas from a pinned GitHub release
3+
# and place them under docs/public/schemas/anolis/ for VitePress to serve statically.
4+
#
5+
# The served URLs match the $id URIs in each schema:
6+
# https://anolishq.github.io/schemas/anolis/runtime/runtime-config.schema.json
7+
# https://anolishq.github.io/schemas/anolis/machine/machine-profile.schema.json
8+
# https://anolishq.github.io/schemas/anolis/telemetry/telemetry-timeseries.schema.v1.json
9+
# https://anolishq.github.io/schemas/anolis/http/runtime-http.openapi.v0.yaml
10+
#
11+
# Pin: schemas/anolis-version.json
12+
13+
set -euo pipefail
14+
15+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
16+
PIN_FILE="${ROOT}/schemas/anolis-version.json"
17+
OUT_BASE="${ROOT}/docs/public/schemas/anolis"
18+
19+
if [ ! -f "${PIN_FILE}" ]; then
20+
echo "ERROR: schema pin file not found: ${PIN_FILE}" >&2
21+
exit 1
22+
fi
23+
24+
VERSION=$(jq -r '.anolis_version' "${PIN_FILE}")
25+
if [ -z "${VERSION}" ] || [ "${VERSION}" = "null" ]; then
26+
echo "ERROR: anolis_version not set in ${PIN_FILE}" >&2
27+
exit 1
28+
fi
29+
30+
echo "Injecting anolis schemas v${VERSION} ..."
31+
32+
BASE_URL="https://github.com/anolishq/anolis/releases/download/v${VERSION}"
33+
34+
# Format: tarball | member path inside tarball | output path relative to OUT_BASE
35+
SCHEMAS=(
36+
"anolis-${VERSION}-runtime-config-schema.tar.gz|schemas/runtime/runtime-config.schema.json|runtime/runtime-config.schema.json"
37+
"anolis-${VERSION}-machine-profile-schema.tar.gz|schemas/machine/machine-profile.schema.json|machine/machine-profile.schema.json"
38+
"anolis-${VERSION}-telemetry-schema.tar.gz|schemas/telemetry/telemetry-timeseries.schema.v1.json|telemetry/telemetry-timeseries.schema.v1.json"
39+
"anolis-${VERSION}-runtime-http-schema.tar.gz|schemas/http/runtime-http.openapi.v0.yaml|http/runtime-http.openapi.v0.yaml"
40+
)
41+
42+
TMP=$(mktemp -d)
43+
trap 'rm -rf "${TMP}"' EXIT
44+
45+
for entry in "${SCHEMAS[@]}"; do
46+
IFS='|' read -r tarball member outrel <<< "${entry}"
47+
url="${BASE_URL}/${tarball}"
48+
tarball_path="${TMP}/${tarball}"
49+
extract_dir="${TMP}/extract-${tarball%.tar.gz}"
50+
out_file="${OUT_BASE}/${outrel}"
51+
52+
echo " Fetching ${url} ..."
53+
curl -fsSL --retry 3 --retry-delay 2 -o "${tarball_path}" "${url}"
54+
55+
mkdir -p "${extract_dir}"
56+
tar -xzf "${tarball_path}" -C "${extract_dir}" --no-same-owner
57+
58+
src="${extract_dir}/${member}"
59+
if [ ! -f "${src}" ]; then
60+
echo "ERROR: expected member '${member}' not found in ${tarball}" >&2
61+
exit 1
62+
fi
63+
64+
mkdir -p "$(dirname "${out_file}")"
65+
cp "${src}" "${out_file}"
66+
echo " -> ${out_file#"${ROOT}/"}"
67+
done
68+
69+
echo ""
70+
echo "Schema injection complete (anolis v${VERSION})"

0 commit comments

Comments
 (0)