colorspaces / deploy.sh
amithjkamath's picture
Update colorspace demo
719e71f
Raw
History Blame Contribute Delete
2.03 kB
#!/bin/bash
# Deployment script for Hugging Face Spaces
set -e
echo "πŸš€ Hugging Face Spaces Deployment Script"
echo "========================================="
echo ""
# Check if git is initialized
if [ ! -d ".git" ]; then
echo "❌ Error: Not a git repository. Initialize with 'git init' first."
exit 1
fi
# Get repository name
read -p "πŸ“ Enter your Hugging Face Space name (e.g., username/colorspaces): " SPACE_NAME
if [ -z "$SPACE_NAME" ]; then
echo "❌ Error: Space name cannot be empty."
exit 1
fi
# Construct the URL
SPACE_URL="https://huggingface.co/spaces/${SPACE_NAME}"
echo ""
echo "πŸ” Checking if remote exists..."
# Check if 'hf' remote already 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..."
# Add all files
git add .
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "ℹ️ No changes to commit."
else
read -p "πŸ’¬ Enter commit message (default: 'Update colorspace demo'): " COMMIT_MSG
COMMIT_MSG=${COMMIT_MSG:-"Update colorspace demo"}
git commit -m "$COMMIT_MSG"
echo "βœ… Changes committed"
fi
echo ""
echo "🚒 Pushing to Hugging Face Spaces..."
echo "This may take a few moments..."
echo ""
# Push to HF
if git push hf main; then
echo ""
echo "βœ… Deployment successful!"
echo ""
echo "🌐 Your Space will be available at:"
echo " $SPACE_URL"
echo ""
echo "⏳ Note: It may take a few minutes for the Space to build and start."
echo " You can check the status with: make status"
else
echo ""
echo "❌ Deployment failed!"
echo ""
echo "Common issues:"
echo " 1. Make sure you're logged in with: huggingface-cli login"
echo " 2. Verify the Space exists on Hugging Face"
echo " 3. Check your network connection"
echo ""
exit 1
fi