ZDDC/deploy
ZDDC 7570fb7494 refactor: separate website repo + deploy-host model
Migrates from in-repo orphan `website` branch + LFS to a two-repo +
deploy-host model so source editing is fully decoupled from live state.

  - Source code stays here (codeberg.org/VARASYS/ZDDC).
  - Hand-edited website content moves to a separate Codeberg repo
    (codeberg.org/VARASYS/ZDDC-website, cloned at ~/src/zddc-website/).
  - Live site is /srv/zddc/ on the deploy host (Caddy bind-mount),
    populated by ./deploy from this repo's dist/release-output/ plus
    ~/src/zddc-website/.
  - Releases are no longer in any git history — reproducible from
    <tool>-vX.Y.Z tags via `./build release X.Y.Z`. No LFS, no
    Codeberg release assets.

Build/deploy split:
  - ./build (no arg) is source-only; nothing in dist/release-output/
    or /srv/zddc/ is touched.
  - ./build alpha|beta|release seeds dist/release-output/ from
    /srv/zddc/releases/ (preserving symlinks), then mutates the
    channel(s) being cut on top. The bundle is always a complete
    intended-live snapshot, so the verifier sees a complete world
    and ./deploy --releases (rsync --delete-after) replaces live
    state cleanly.
  - New ./deploy wraps the rsync flow with --content / --releases
    subcommands.

Docs updated to reflect the new model: CLAUDE.md, AGENTS.md,
ARCHITECTURE.md, zddc/README.md, README.md, .gitignore, shared/
build-lib.sh comments, deprecated zddc/release.sh message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 09:14:40 -05:00

91 lines
3.2 KiB
Bash
Executable file

#!/bin/sh
set -eu
# deploy — sync built artifacts and/or hand-edited content to the live site.
#
# The build pipeline (`./build alpha|beta|release`) produces self-contained
# bundles in dist/release-output/ but does NOT touch the live site. This
# script is the explicit deploy step. Two sync paths, independent:
#
# ./deploy push everything: content + releases
# ./deploy --content push only ~/src/zddc-website/ → /srv/zddc/
# (excludes /releases/ so releases stay intact)
# ./deploy --releases push only dist/release-output/ → /srv/zddc/releases/
#
# Both paths use rsync with --delete-after, so the live tree exactly
# mirrors the source — files removed locally go away on the live site.
# Mostly-atomic per-file; brief mixed-state during a sync is acceptable
# for a low-traffic static site. Caddy bind-mounts /srv/zddc as :ro and
# serves whatever is there at request time.
#
# Override the source paths via env if you want:
# ZDDC_CONTENT_DIR default: ~/src/zddc-website
# ZDDC_DEPLOY_RELEASES_DIR default: <this-script-dir>/dist/release-output
# ZDDC_LIVE_DIR default: /srv/zddc
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
CONTENT_SRC="${ZDDC_CONTENT_DIR:-$HOME/src/zddc-website}"
RELEASES_SRC="${ZDDC_DEPLOY_RELEASES_DIR:-$SCRIPT_DIR/dist/release-output}"
LIVE="${ZDDC_LIVE_DIR:-/srv/zddc}"
case "${1:-all}" in
-h|--help|help)
sed -n '4,21p' "$0" | sed 's/^# \{0,1\}//'
exit 0
;;
--content|content)
WHAT=content
;;
--releases|releases)
WHAT=releases
;;
all|"")
WHAT=all
;;
*)
echo "deploy: unknown subcommand '$1'. Try './deploy help'." >&2
exit 1
;;
esac
if [ ! -d "$LIVE" ]; then
echo "deploy: $LIVE does not exist. Create it and chown to your user first:" >&2
echo " sudo mkdir -p $LIVE && sudo chown -R \$USER:\$USER $LIVE" >&2
exit 1
fi
if [ "$WHAT" = content ] || [ "$WHAT" = all ]; then
if [ ! -d "$CONTENT_SRC" ]; then
echo "deploy: content source $CONTENT_SRC does not exist" >&2
exit 1
fi
echo "=== Syncing content: $CONTENT_SRC/ → $LIVE/ ==="
# --exclude=/releases/ keeps the live site's releases dir untouched
# by content syncs. --exclude=.git so the .git dir doesn't end up
# under /usr/share/caddy.
rsync -av --delete-after \
--exclude='/releases/' \
--exclude='/.git*' \
--exclude='/README.md' \
--exclude='/LICENSE' \
"$CONTENT_SRC/" "$LIVE/"
fi
if [ "$WHAT" = releases ] || [ "$WHAT" = all ]; then
if [ ! -d "$RELEASES_SRC" ] || [ -z "$(ls -A "$RELEASES_SRC" 2>/dev/null)" ]; then
echo "deploy: releases source $RELEASES_SRC is empty or missing" >&2
echo " Run ./build alpha|beta|release first to populate it." >&2
if [ "$WHAT" = all ]; then
echo " (Skipping releases sync; content was synced.)" >&2
exit 0
fi
exit 1
fi
mkdir -p "$LIVE/releases"
echo "=== Syncing releases: $RELEASES_SRC/ → $LIVE/releases/ ==="
rsync -av --delete-after "$RELEASES_SRC/" "$LIVE/releases/"
fi
echo ""
echo "=== Deploy done ==="
echo "Live: https://zddc.varasys.io/"