| #!/bin/bash |
|
|
| |
|
|
| set -e |
|
|
| echo "π Hugging Face Spaces Deployment Script" |
| echo "=========================================" |
| echo "" |
|
|
| |
| if [ ! -d ".git" ]; then |
| echo "β Error: Not a git repository. Initialize with 'git init' first." |
| exit 1 |
| fi |
|
|
| |
| read -p "π Enter your Hugging Face Space name (e.g., username/space-name): " SPACE_NAME |
|
|
| if [ -z "$SPACE_NAME" ]; then |
| echo "β Error: Space name cannot be empty." |
| exit 1 |
| fi |
|
|
| |
| SPACE_URL="https://huggingface.co/spaces/${SPACE_NAME}" |
|
|
| echo "" |
| echo "π Checking if remote exists..." |
|
|
| |
| if git remote | grep -q "hf"; then |
| echo "β
Remote 'hf' already exists. Updating URL..." |
| git remote set-url hf "$SPACE_URL" |
| else |
| echo "β Adding remote 'hf'..." |
| git remote add hf "$SPACE_URL" |
| fi |
|
|
| echo "" |
| echo "π¦ Committing changes..." |
|
|
| |
| git add . |
|
|
| |
| if git diff --staged --quiet; then |
| echo "βΉοΈ No changes to commit." |
| else |
| read -p "π¬ Enter commit message (default: 'Update demo'): " COMMIT_MSG |
| COMMIT_MSG=${COMMIT_MSG:-"Update demo"} |
| git commit -m "$COMMIT_MSG" |
| fi |
|
|
| echo "" |
| echo "π Pushing to Hugging Face Spaces..." |
| git push hf main |
|
|
| echo "" |
| echo "β
Deployment complete!" |
| echo "π Your Space will be available at: $SPACE_URL" |
| echo "" |
| echo "β±οΈ Note: It may take a few minutes for the Space to build and start." |
|
|