NumericalOS

scripts/publish-site.sh

back to source

#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Build + deploy full NumericalOS site to numericalos.com (Cloudflare Pages).
# Self-hosted: no git remote required.
set -euo pipefail

REPO="$(cd "$(dirname "$0")/.." && pwd)"
PROJECT="${PROJECT:-numericalos}"
BRANCH="${BRANCH:-main}"
CANONICAL="${CANONICAL:-https://numericalos.com}"
SKIP_TESTS="${SKIP_TESTS:-0}"
cd "$REPO"

echo "=== numericalos-publish-site ==="
echo "repo=$REPO"

if [[ ! -f site/build.py ]]; then
  echo "ERROR: site/build.py missing" >&2
  exit 1
fi

if [[ "$SKIP_TESTS" != "1" ]]; then
  echo "--- tests ---"
  if command -v py >/dev/null 2>&1; then
    py -3 -m unittest tests.test_principles -q
  else
    python3 -m unittest tests.test_principles -q
  fi
fi

echo "--- build ---"
if command -v py >/dev/null 2>&1; then
  py -3 site/build.py
else
  python3 site/build.py
fi
DEPLOY_DIR="${NUMOS_OUT:-$REPO/public}"
[[ -f "$DEPLOY_DIR/index.html" ]] || { echo "no index.html in $DEPLOY_DIR" >&2; exit 1; }

echo "--- deploy project=$PROJECT branch=$BRANCH ---"
npx --yes wrangler pages deploy "$DEPLOY_DIR" \
  --project-name "$PROJECT" \
  --branch "$BRANCH" \
  --commit-dirty=true

echo "--- live probes $CANONICAL ---"
for p in / /docs/status/ /skills/ /whitepaper/ /principles/ /browse/ /index.json; do
  code=$(curl -sS -o /dev/null -w "%{http_code}" --max-time 30 "${CANONICAL}${p}" || echo err)
  printf '%-20s HTTP %s\n' "$p" "$code"
done

echo "publish-site done (self-hosted; no git remote required)"