#!/usr/bin/env bash # Deploy Aether Garden to Hugging Face Spaces + backup world state to HF Dataset. set -euo pipefail cd "$(dirname "$0")/.." source .venv/bin/activate if [[ ! -f .env ]]; then echo "Missing .env — copy .env.example and fill in HF_TOKEN, HF_DATASET_REPO, MODAL_INFERENCE_URL" exit 1 fi set -a source .env set +a SPACE_ID="${HF_SPACE_ID:-kavyabhand/aether-garden}" DATASET_ID="${HF_DATASET_REPO:-kavyabhand/aether-garden-world-state}" echo "Logging in to Hugging Face..." hf auth login --token "$HF_TOKEN" 2>/dev/null || true echo "Creating repos (skipped if they already exist)..." hf repos create "$SPACE_ID" --type space --space-sdk gradio --public --exist-ok || { echo "Could not create Space. Create it manually at https://huggingface.co/new-space" echo " Owner: your username | Name: aether-garden | SDK: Gradio" } hf repos create "$DATASET_ID" --type dataset --private --exist-ok || { echo "Could not create dataset. Create manually at https://huggingface.co/new-dataset" echo " Name: aether-garden-world-state | Private: yes" } if [[ -f data/world.db ]]; then echo "Uploading world.db to dataset $DATASET_ID..." hf upload "$DATASET_ID" data/world.db world.db --repo-type dataset \ --commit-message "World state backup for Aether Garden" fi echo "Uploading Space README..." hf upload "$SPACE_ID" README_HF_SPACE.md README.md --repo-type space \ --commit-message "Configure Gradio Space" echo "Uploading application files..." hf upload "$SPACE_ID" . . --repo-type space \ --exclude ".env" \ --exclude ".env.*" \ --exclude ".venv/**" \ --exclude "data/**" \ --exclude ".git/**" \ --exclude "__pycache__/**" \ --exclude "**/__pycache__/**" \ --exclude "*.pyc" \ --exclude "DETAILS.md" \ --exclude "DEPLOYMENT.md" \ --exclude "scripts/**" \ --exclude "modal_app.py" \ --exclude "README.md" \ --exclude ".gitignore" \ --commit-message "Deploy Aether Garden application" echo "Setting Space secrets..." TMP_SECRETS=$(mktemp) cat > "$TMP_SECRETS" <