feat(build): Scripts et configuration pour build production
- Ajout de scripts PowerShell et Bash pour build automatisé - Configuration pour connexion à l'API production (api.lions.dev/afterwork) - Documentation complète dans BUILD_CONFIG.md - Fichier .env.example pour référence - Support pour APK, App Bundle, iOS et Web
This commit is contained in:
82
scripts/build_production.ps1
Normal file
82
scripts/build_production.ps1
Normal file
@@ -0,0 +1,82 @@
|
||||
# Script de build pour la production
|
||||
# Usage: .\scripts\build_production.ps1
|
||||
|
||||
param(
|
||||
[string]$Platform = "apk", # apk, appbundle, ios, web
|
||||
[switch]$Clean = $false
|
||||
)
|
||||
|
||||
Write-Host "🚀 Build AfterWork pour la production..." -ForegroundColor Cyan
|
||||
Write-Host " Plateforme: $Platform" -ForegroundColor Gray
|
||||
|
||||
# Configuration de production
|
||||
$API_BASE_URL = "https://api.lions.dev/afterwork"
|
||||
$ENVIRONMENT = "production"
|
||||
|
||||
# Nettoyage si demandé
|
||||
if ($Clean) {
|
||||
Write-Host "`n🧹 Nettoyage du projet..." -ForegroundColor Yellow
|
||||
flutter clean
|
||||
flutter pub get
|
||||
}
|
||||
|
||||
# Définir les dart-defines
|
||||
$dartDefines = @(
|
||||
"API_BASE_URL=$API_BASE_URL",
|
||||
"ENVIRONMENT=$ENVIRONMENT"
|
||||
)
|
||||
|
||||
$dartDefineArgs = $dartDefines | ForEach-Object { "--dart-define=$_" }
|
||||
|
||||
Write-Host "`n📝 Configuration:" -ForegroundColor Yellow
|
||||
Write-Host " API_BASE_URL: $API_BASE_URL" -ForegroundColor Gray
|
||||
Write-Host " ENVIRONMENT: $ENVIRONMENT" -ForegroundColor Gray
|
||||
|
||||
# Build selon la plateforme
|
||||
Write-Host "`n🔨 Build en cours..." -ForegroundColor Yellow
|
||||
|
||||
switch ($Platform.ToLower()) {
|
||||
"apk" {
|
||||
Write-Host " Création de l'APK..." -ForegroundColor Gray
|
||||
flutter build apk @dartDefineArgs --release
|
||||
$outputPath = "build\app\outputs\flutter-apk\app-release.apk"
|
||||
}
|
||||
"appbundle" {
|
||||
Write-Host " Création de l'App Bundle..." -ForegroundColor Gray
|
||||
flutter build appbundle @dartDefineArgs --release
|
||||
$outputPath = "build\app\outputs\bundle\release\app-release.aab"
|
||||
}
|
||||
"ios" {
|
||||
Write-Host " Création de l'IPA iOS..." -ForegroundColor Gray
|
||||
flutter build ios @dartDefineArgs --release
|
||||
$outputPath = "build\ios\ipa"
|
||||
}
|
||||
"web" {
|
||||
Write-Host " Création du build Web..." -ForegroundColor Gray
|
||||
flutter build web @dartDefineArgs --release
|
||||
$outputPath = "build\web"
|
||||
}
|
||||
default {
|
||||
Write-Host " ❌ Plateforme non supportée: $Platform" -ForegroundColor Red
|
||||
Write-Host " Plateformes disponibles: apk, appbundle, ios, web" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Vérifier le succès du build
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "`n✅ Build terminé avec succès!" -ForegroundColor Green
|
||||
Write-Host "`n📦 Fichier de sortie:" -ForegroundColor Cyan
|
||||
Write-Host " $outputPath" -ForegroundColor White
|
||||
|
||||
if (Test-Path $outputPath) {
|
||||
$size = (Get-Item $outputPath -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum
|
||||
if ($size) {
|
||||
$sizeMB = [math]::Round($size / 1MB, 2)
|
||||
Write-Host " Taille: $sizeMB MB" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Host "`n❌ Le build a échoué!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
99
scripts/build_production.sh
Normal file
99
scripts/build_production.sh
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script de build pour la production
|
||||
# Usage: ./scripts/build_production.sh [platform] [--clean]
|
||||
# Platforms: apk, appbundle, ios, web
|
||||
|
||||
set -e
|
||||
|
||||
# Couleurs pour le terminal
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
GRAY='\033[0;90m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
PLATFORM="${1:-apk}"
|
||||
CLEAN=false
|
||||
|
||||
# Vérifier les arguments
|
||||
if [[ "$2" == "--clean" || "$1" == "--clean" ]]; then
|
||||
CLEAN=true
|
||||
fi
|
||||
|
||||
# Configuration de production
|
||||
API_BASE_URL="https://api.lions.dev/afterwork"
|
||||
ENVIRONMENT="production"
|
||||
|
||||
echo -e "${CYAN}🚀 Build AfterWork pour la production...${NC}"
|
||||
echo -e "${GRAY} Plateforme: $PLATFORM${NC}"
|
||||
|
||||
# Nettoyage si demandé
|
||||
if [ "$CLEAN" = true ]; then
|
||||
echo -e "\n${YELLOW}🧹 Nettoyage du projet...${NC}"
|
||||
flutter clean
|
||||
flutter pub get
|
||||
fi
|
||||
|
||||
# Dart defines
|
||||
DART_DEFINES=(
|
||||
"--dart-define=API_BASE_URL=$API_BASE_URL"
|
||||
"--dart-define=ENVIRONMENT=$ENVIRONMENT"
|
||||
)
|
||||
|
||||
echo -e "\n${YELLOW}📝 Configuration:${NC}"
|
||||
echo -e "${GRAY} API_BASE_URL: $API_BASE_URL${NC}"
|
||||
echo -e "${GRAY} ENVIRONMENT: $ENVIRONMENT${NC}"
|
||||
|
||||
# Build selon la plateforme
|
||||
echo -e "\n${YELLOW}🔨 Build en cours...${NC}"
|
||||
|
||||
case "$PLATFORM" in
|
||||
apk)
|
||||
echo -e "${GRAY} Création de l'APK...${NC}"
|
||||
flutter build apk "${DART_DEFINES[@]}" --release
|
||||
OUTPUT_PATH="build/app/outputs/flutter-apk/app-release.apk"
|
||||
;;
|
||||
appbundle)
|
||||
echo -e "${GRAY} Création de l'App Bundle...${NC}"
|
||||
flutter build appbundle "${DART_DEFINES[@]}" --release
|
||||
OUTPUT_PATH="build/app/outputs/bundle/release/app-release.aab"
|
||||
;;
|
||||
ios)
|
||||
echo -e "${GRAY} Création de l'IPA iOS...${NC}"
|
||||
flutter build ios "${DART_DEFINES[@]}" --release
|
||||
OUTPUT_PATH="build/ios/ipa"
|
||||
;;
|
||||
web)
|
||||
echo -e "${GRAY} Création du build Web...${NC}"
|
||||
flutter build web "${DART_DEFINES[@]}" --release
|
||||
OUTPUT_PATH="build/web"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED} ❌ Plateforme non supportée: $PLATFORM${NC}"
|
||||
echo -e "${YELLOW} Plateformes disponibles: apk, appbundle, ios, web${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Vérifier le succès du build
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "\n${GREEN}✅ Build terminé avec succès!${NC}"
|
||||
echo -e "\n${CYAN}📦 Fichier de sortie:${NC}"
|
||||
echo -e " ${OUTPUT_PATH}"
|
||||
|
||||
if [ -e "$OUTPUT_PATH" ]; then
|
||||
if [ -f "$OUTPUT_PATH" ]; then
|
||||
SIZE=$(du -h "$OUTPUT_PATH" | cut -f1)
|
||||
echo -e "${GRAY} Taille: $SIZE${NC}"
|
||||
elif [ -d "$OUTPUT_PATH" ]; then
|
||||
SIZE=$(du -sh "$OUTPUT_PATH" | cut -f1)
|
||||
echo -e "${GRAY} Taille: $SIZE${NC}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "\n${RED}❌ Le build a échoué!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user