161 lines
6.4 KiB
Bash
Executable File
161 lines
6.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ─────────────────────────────────────────────────────────────
|
|
# SENTINEL ONE — Script de generación de build
|
|
# ─────────────────────────────────────────────────────────────
|
|
|
|
CYAN='\033[0;36m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
BOLD='\033[1m'
|
|
RESET='\033[0m'
|
|
|
|
echo ""
|
|
echo -e "${CYAN}${BOLD}╔══════════════════════════════════════╗${RESET}"
|
|
echo -e "${CYAN}${BOLD}║ SENTINEL ONE — Build Tool ║${RESET}"
|
|
echo -e "${CYAN}${BOLD}╚══════════════════════════════════════╝${RESET}"
|
|
echo ""
|
|
|
|
# ── Selección de plataforma ───────────────────────────────────
|
|
echo -e "${BOLD}Selecciona la plataforma:${RESET}"
|
|
echo ""
|
|
echo " 1) Android — APK release"
|
|
echo " 2) Android — APK debug"
|
|
echo " 3) Android — App Bundle (.aab) para Play Store"
|
|
echo " 4) Linux — Ejecutable de escritorio"
|
|
echo " 5) Web — Sitio estático"
|
|
echo ""
|
|
read -p "Opción [1-5]: " opcion
|
|
|
|
echo ""
|
|
|
|
case $opcion in
|
|
|
|
# ── Android APK release ──────────────────────────────────────
|
|
1)
|
|
echo -e "${YELLOW}▶ Generando APK release para Android...${RESET}"
|
|
flutter build apk --release
|
|
if [ $? -eq 0 ]; then
|
|
APK="build/app/outputs/flutter-apk/app-release.apk"
|
|
SIZE=$(du -sh "$APK" | cut -f1)
|
|
echo ""
|
|
echo -e "${GREEN}${BOLD}✓ APK generado correctamente${RESET}"
|
|
echo -e " Archivo : ${BOLD}$APK${RESET}"
|
|
echo -e " Tamaño : ${BOLD}$SIZE${RESET}"
|
|
echo ""
|
|
read -p "¿Instalar en dispositivo conectado por ADB? [s/N]: " instalar
|
|
if [[ "$instalar" =~ ^[sS]$ ]]; then
|
|
echo -e "${YELLOW}▶ Instalando...${RESET}"
|
|
adb install -r "$APK"
|
|
[ $? -eq 0 ] && echo -e "${GREEN}✓ Instalado correctamente${RESET}" \
|
|
|| echo -e "${RED}✗ Error al instalar. Verifica que el dispositivo esté conectado.${RESET}"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Error al generar el APK.${RESET}"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
# ── Android APK debug ────────────────────────────────────────
|
|
2)
|
|
echo -e "${YELLOW}▶ Generando APK debug para Android...${RESET}"
|
|
flutter build apk --debug
|
|
if [ $? -eq 0 ]; then
|
|
APK="build/app/outputs/flutter-apk/app-debug.apk"
|
|
SIZE=$(du -sh "$APK" | cut -f1)
|
|
echo ""
|
|
echo -e "${GREEN}${BOLD}✓ APK debug generado${RESET}"
|
|
echo -e " Archivo : ${BOLD}$APK${RESET}"
|
|
echo -e " Tamaño : ${BOLD}$SIZE${RESET}"
|
|
echo ""
|
|
read -p "¿Instalar en dispositivo conectado por ADB? [s/N]: " instalar
|
|
if [[ "$instalar" =~ ^[sS]$ ]]; then
|
|
echo -e "${YELLOW}▶ Instalando...${RESET}"
|
|
adb install -r "$APK"
|
|
[ $? -eq 0 ] && echo -e "${GREEN}✓ Instalado correctamente${RESET}" \
|
|
|| echo -e "${RED}✗ Error al instalar.${RESET}"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Error al generar el APK debug.${RESET}"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
# ── Android App Bundle ───────────────────────────────────────
|
|
3)
|
|
echo -e "${YELLOW}▶ Generando App Bundle (.aab) para Play Store...${RESET}"
|
|
flutter build appbundle --release
|
|
if [ $? -eq 0 ]; then
|
|
AAB="build/app/outputs/bundle/release/app-release.aab"
|
|
SIZE=$(du -sh "$AAB" | cut -f1)
|
|
echo ""
|
|
echo -e "${GREEN}${BOLD}✓ App Bundle generado${RESET}"
|
|
echo -e " Archivo : ${BOLD}$AAB${RESET}"
|
|
echo -e " Tamaño : ${BOLD}$SIZE${RESET}"
|
|
echo ""
|
|
echo -e " ${CYAN}Sube este archivo a Google Play Console para publicar.${RESET}"
|
|
else
|
|
echo -e "${RED}✗ Error al generar el App Bundle.${RESET}"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
# ── Linux desktop ────────────────────────────────────────────
|
|
4)
|
|
echo -e "${YELLOW}▶ Generando ejecutable para Linux...${RESET}"
|
|
flutter build linux --release
|
|
if [ $? -eq 0 ]; then
|
|
DIR="build/linux/x64/release/bundle"
|
|
SIZE=$(du -sh "$DIR" | cut -f1)
|
|
echo ""
|
|
echo -e "${GREEN}${BOLD}✓ Build Linux generado${RESET}"
|
|
echo -e " Directorio : ${BOLD}$DIR${RESET}"
|
|
echo -e " Tamaño : ${BOLD}$SIZE${RESET}"
|
|
echo ""
|
|
read -p "¿Ejecutar ahora? [s/N]: " ejecutar
|
|
if [[ "$ejecutar" =~ ^[sS]$ ]]; then
|
|
echo -e "${YELLOW}▶ Ejecutando...${RESET}"
|
|
"$DIR/seguridad_electronica" &
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Error al generar build Linux.${RESET}"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
# ── Web ──────────────────────────────────────────────────────
|
|
5)
|
|
echo -e "${YELLOW}▶ Generando build Web...${RESET}"
|
|
flutter build web --release
|
|
if [ $? -eq 0 ]; then
|
|
DIR="build/web"
|
|
SIZE=$(du -sh "$DIR" | cut -f1)
|
|
echo ""
|
|
echo -e "${GREEN}${BOLD}✓ Build Web generado${RESET}"
|
|
echo -e " Directorio : ${BOLD}$DIR${RESET}"
|
|
echo -e " Tamaño : ${BOLD}$SIZE${RESET}"
|
|
echo ""
|
|
read -p "¿Servir localmente con flutter serve? [s/N]: " servir
|
|
if [[ "$servir" =~ ^[sS]$ ]]; then
|
|
echo -e "${YELLOW}▶ Iniciando servidor en http://localhost:8080 ...${RESET}"
|
|
flutter run -d web-server --web-port 8080
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Error al generar build Web.${RESET}"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo -e "${RED}Opción inválida. Ejecuta el script de nuevo.${RESET}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo -e "${CYAN}${BOLD}══════════════════════════════════════${RESET}"
|
|
echo -e "${GREEN}${BOLD} Build finalizado — SENTINEL ONE${RESET}"
|
|
echo -e "${CYAN}${BOLD}══════════════════════════════════════${RESET}"
|
|
echo ""
|