|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
RED='\033[0;31m' |
|
|
GREEN='\033[0;32m' |
|
|
YELLOW='\033[1;33m' |
|
|
BLUE='\033[0;34m' |
|
|
NC='\033[0m' |
|
|
|
|
|
|
|
|
print_message() { |
|
|
echo -e "${GREEN}[INFO]${NC} $1" |
|
|
} |
|
|
|
|
|
print_warning() { |
|
|
echo -e "${YELLOW}[WARNING]${NC} $1" |
|
|
} |
|
|
|
|
|
print_error() { |
|
|
echo -e "${RED}[ERROR]${NC} $1" |
|
|
} |
|
|
|
|
|
print_header() { |
|
|
echo -e "${BLUE}================================${NC}" |
|
|
echo -e "${BLUE}$1${NC}" |
|
|
echo -e "${BLUE}================================${NC}" |
|
|
} |
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then |
|
|
print_error "Debes proporcionar un nombre para el Space" |
|
|
echo "Uso: ./deploy.sh [nombre-del-space]" |
|
|
echo "Ejemplo: ./deploy.sh modelos-libres-ia" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
SPACE_NAME=$1 |
|
|
USERNAME=$(git config user.name || echo "tu-usuario") |
|
|
|
|
|
print_header "🚀 Desplegando Space: $SPACE_NAME" |
|
|
|
|
|
|
|
|
if [ ! -f "app.py" ]; then |
|
|
print_error "No se encontró app.py. Asegúrate de estar en el directorio correcto." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
if ! git config user.name > /dev/null 2>&1; then |
|
|
print_warning "Git no está configurado. Configurando..." |
|
|
read -p "Ingresa tu nombre de usuario de Git: " git_username |
|
|
read -p "Ingresa tu email de Git: " git_email |
|
|
git config user.name "$git_username" |
|
|
git config user.email "$git_email" |
|
|
fi |
|
|
|
|
|
|
|
|
if ! python -c "import huggingface_hub" > /dev/null 2>&1; then |
|
|
print_warning "Instalando huggingface_hub..." |
|
|
pip install huggingface_hub |
|
|
fi |
|
|
|
|
|
print_message "Inicializando repositorio Git..." |
|
|
git init |
|
|
git add . |
|
|
|
|
|
print_message "Haciendo commit inicial..." |
|
|
git commit -m "Initial commit: Modelos libres de IA" |
|
|
|
|
|
print_message "Creando Space en Hugging Face..." |
|
|
huggingface-cli repo create $SPACE_NAME --type space --space-sdk gradio |
|
|
|
|
|
print_message "Configurando el repositorio remoto..." |
|
|
git remote add origin https://huggingface.co/spaces/$USERNAME/$SPACE_NAME |
|
|
|
|
|
print_message "Subiendo archivos al Space..." |
|
|
git push -u origin main |
|
|
|
|
|
print_header "✅ ¡Space creado exitosamente!" |
|
|
|
|
|
echo -e "${GREEN}Tu Space está disponible en:${NC}" |
|
|
echo -e "${BLUE}https://huggingface.co/spaces/$USERNAME/$SPACE_NAME${NC}" |
|
|
echo "" |
|
|
echo -e "${YELLOW}Próximos pasos:${NC}" |
|
|
echo "1. Ve a la URL del Space" |
|
|
echo "2. Espera a que se construya (puede tomar unos minutos)" |
|
|
echo "3. ¡Disfruta usando tus modelos libres!" |
|
|
echo "" |
|
|
echo -e "${YELLOW}Para actualizar el Space en el futuro:${NC}" |
|
|
echo "git add ." |
|
|
echo "git commit -m 'Actualización'" |
|
|
echo "git push" |
|
|
echo "" |
|
|
print_message "¡Despliegue completado! 🎉" |