| #!/bin/bash |
| set -e |
|
|
| cd "$(dirname "$0")" |
|
|
| echo "=== AirMicroDrip HF Space Deployment ===" |
|
|
| |
| SPACE_ID="${HF_SPACE_ID:-josephrw/membra-airmicrodrip}" |
| TOKEN="${HF_TOKEN:-${HUGGINGFACE_TOKEN:-${HUGGING_FACE_TOKEN:-}}}" |
|
|
| if [ -z "$TOKEN" ]; then |
| echo "ERROR: Set HF_TOKEN environment variable" |
| exit 1 |
| fi |
|
|
| echo "Space: $SPACE_ID" |
|
|
| |
| if [ ! -d .git ]; then |
| git init |
| git config user.email "deploy@membra.ai" |
| git config user.name "MEMBRA Deploy" |
| fi |
|
|
| |
| if ! git remote | grep -q origin; then |
| git remote add origin "https://huggingface.co/spaces/$SPACE_ID" |
| fi |
|
|
| |
| git add -A |
|
|
| |
| git commit -m "Deploy AirMicroDrip - no mocks, real APIs" || echo "Nothing new to commit" |
|
|
| |
| echo "Pushing to Hugging Face..." |
| git remote set-url origin "https://huggingface.co/spaces/$SPACE_ID" |
| askpass_file="$(mktemp)" |
| cat > "$askpass_file" <<'ASKPASS' |
| |
| case "$1" in |
| *Username*) printf '%s\n' "user" ;; |
| *Password*) printf '%s\n' "$HF_TOKEN" ;; |
| *) printf '\n' ;; |
| esac |
| ASKPASS |
| chmod 700 "$askpass_file" |
| trap 'rm -f "$askpass_file"' EXIT |
|
|
| if ! GIT_ASKPASS="$askpass_file" git push origin main --force 2>&1; then |
| echo "" |
| echo "ERROR: Git push failed. Possible causes:" |
| echo " 1. Token is invalid or expired" |
| echo " 2. Token lacks 'write' permission for Spaces" |
| echo " 3. Space does not exist and token cannot create Spaces" |
| exit 1 |
| fi |
|
|
| echo "" |
| echo "=== Deployed ===" |
| echo "Space: https://huggingface.co/spaces/$SPACE_ID" |
| echo "" |
| echo "Set environment variables in Space Settings:" |
| echo " TOKEN_MINT=<your_solana_token_mint>" |
| echo " INFERENCE_API_URL=<your_llm_endpoint>" |
| echo " SOLANA_RPC_URL=https://api.devnet.solana.com" |
|
|