#!/usr/bin/env bash # Deploy hf_staging/ to Hugging Face Spaces (default: kinaar111/staging) set -euo pipefail SPACE_ID="${HF_SPACE_ID:-kinaar111/staging}" ROOT="$(cd "$(dirname "$0")/.." && pwd)" COMMIT_MSG="${1:-Update 6-string optimizer staging Space}" cd "$ROOT" if ! command -v hf &>/dev/null; then echo "hf CLI not found. Install: curl -LsSf https://hf.co/cli/install.sh | bash" exit 1 fi if ! hf auth whoami &>/dev/null; then echo "Not logged in. Run: hf auth login" exit 1 fi COMMIT_HASH="local" if git -C "$(dirname "$ROOT")" rev-parse --short HEAD &>/dev/null 2>&1; then COMMIT_HASH="$(git -C "$(dirname "$ROOT")" rev-parse --short HEAD)" fi UTC_NOW="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" cat > "$ROOT/build_info.py" </dev/null; then hf repos create "$SPACE_ID" \ --type space \ --space-sdk gradio \ --public \ --exist-ok fi echo "Deploying to ${SPACE_ID}..." hf upload "$SPACE_ID" "$ROOT" . \ --repo-type space \ --commit-message "$COMMIT_MSG" \ --exclude ".cache/**" \ --exclude "**/__pycache__/**" \ --exclude "**/*.pyc" \ --exclude ".venv/**" echo "Done. Space: https://huggingface.co/spaces/${SPACE_ID}"