feat: Versioning automatique YY.MM.DD.NN pour DEV
- Système 100% automatique de numérotation de version - Format : YY.MM.DD.NN (ex: 26.01.27.01) - Détection automatique de la date du jour - Incrémentation auto du build number (.01 → .02 → .03...) - Reset auto à .01 lors d'un changement de date - Compatible avec ancien format (conversion auto) Logique : 1. Récupération date système : date +%y.%m.%d 2. Si date différente de VERSION → YY.MM.DD.01 3. Si même date → incrémenter dernier nombre 4. Écriture dans VERSION et pubspec.yaml Exemple : - 26/01 build 1 → 26.01.26.01 - 26/01 build 2 → 26.01.26.02 - 27/01 build 1 → 26.01.27.01 (reset auto) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,8 @@ set -euo pipefail
|
||||
START_TIME=$(($(date +%s%N)/1000000))
|
||||
echo "[$(date '+%H:%M:%S.%3N')] Début du script deploy-app.sh"
|
||||
|
||||
cd /home/pierre/dev/geosector/app
|
||||
# Note: Le code source est sur IN1:/home/pierre/dev/geosector/app
|
||||
# Ce script peut être lancé depuis n'importe où (desktop/laptop)
|
||||
|
||||
# =====================================
|
||||
# Configuration générale
|
||||
@@ -144,51 +145,114 @@ ARCHIVE_NAME="app-deploy-${TIMESTAMP}.tar.gz"
|
||||
TEMP_ARCHIVE="/tmp/${ARCHIVE_NAME}"
|
||||
|
||||
if [ "$SOURCE_TYPE" = "local_build" ]; then
|
||||
# DEV: Build Flutter et créer une archive
|
||||
echo_step "Building Flutter app for DEV..."
|
||||
# DEV: Build Flutter sur IN1 et créer une archive
|
||||
echo_step "Building Flutter app on IN1 for DEV..."
|
||||
|
||||
# Configuration du cache local (partagé web + iOS/Android)
|
||||
echo_info "📦 Configuration du cache local pour builds web et mobile..."
|
||||
export PUB_CACHE="$PWD/.pub-cache-local"
|
||||
export GRADLE_USER_HOME="$PWD/.gradle-local"
|
||||
mkdir -p "$PUB_CACHE" "$GRADLE_USER_HOME"
|
||||
# Variables pour IN1
|
||||
IN1_HOST="IN1"
|
||||
IN1_PROJECT_PATH="/home/pierre/dev/geosector/app"
|
||||
|
||||
echo_info " Cache Pub: $PUB_CACHE"
|
||||
echo_info " Cache Gradle: $GRADLE_USER_HOME"
|
||||
echo_info " → Packages patchés seront prêts pour transfert iOS/Android"
|
||||
echo_info "🖥️ Compilation distante sur IN1:${IN1_PROJECT_PATH}"
|
||||
|
||||
# Charger les variables d'environnement
|
||||
# Charger les variables d'environnement localement pour la version
|
||||
if [ ! -f .env-deploy-dev ]; then
|
||||
echo_error "Missing .env-deploy-dev file"
|
||||
fi
|
||||
source .env-deploy-dev
|
||||
|
||||
# Mise à jour de la version
|
||||
echo_info "Managing version..."
|
||||
# Système automatique de versioning YY.MM.DD.NN
|
||||
echo_info "Managing version (automatic YY.MM.DD.NN)..."
|
||||
|
||||
# Date du jour au format YY.MM.DD
|
||||
TODAY=$(date +%y.%m.%d)
|
||||
|
||||
if [ -f ../VERSION ]; then
|
||||
VERSION=$(cat ../VERSION | tr -d '\n\r' | tr -d ' ')
|
||||
echo_info "Version found: $VERSION"
|
||||
CURRENT_VERSION=$(cat ../VERSION | tr -d '\n\r' | tr -d ' ')
|
||||
echo_info "Current version: $CURRENT_VERSION"
|
||||
|
||||
# Extraire la partie date et le build number
|
||||
if [[ $CURRENT_VERSION =~ ^([0-9]{2}\.[0-9]{2}\.[0-9]{2})\.([0-9]{2})$ ]]; then
|
||||
VERSION_DATE="${BASH_REMATCH[1]}"
|
||||
BUILD_NUM="${BASH_REMATCH[2]}"
|
||||
|
||||
# Si la date a changé, reset à .01
|
||||
if [ "$VERSION_DATE" != "$TODAY" ]; then
|
||||
NEW_BUILD="01"
|
||||
echo_info "Date changed: $VERSION_DATE → $TODAY, resetting build to 01"
|
||||
else
|
||||
echo_warning "VERSION file not found"
|
||||
read -p "Enter version number (x.x.x format): " VERSION
|
||||
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
# Incrémenter le build number
|
||||
NEW_BUILD=$(printf "%02d" $((10#$BUILD_NUM + 1)))
|
||||
echo_info "Same date, incrementing build: $BUILD_NUM → $NEW_BUILD"
|
||||
fi
|
||||
else
|
||||
# Format ancien ou invalide, créer nouveau format
|
||||
NEW_BUILD="01"
|
||||
echo_warning "Old version format detected, creating new format"
|
||||
fi
|
||||
else
|
||||
# Pas de fichier VERSION, créer avec .01
|
||||
NEW_BUILD="01"
|
||||
echo_warning "VERSION file not found, creating new one"
|
||||
fi
|
||||
|
||||
# Construire la nouvelle version complète
|
||||
VERSION="${TODAY}.${NEW_BUILD}"
|
||||
echo "$VERSION" > ../VERSION
|
||||
echo_info "VERSION file created with $VERSION"
|
||||
else
|
||||
echo_error "Invalid version format"
|
||||
fi
|
||||
fi
|
||||
echo_success "✅ New version: $VERSION"
|
||||
|
||||
# Génération du build number et mise à jour du pubspec.yaml
|
||||
BUILD_NUMBER=$(echo $VERSION | tr -d '.')
|
||||
FULL_VERSION="${VERSION}+${BUILD_NUMBER}"
|
||||
echo_info "Full version: $FULL_VERSION"
|
||||
echo_info "Full version for pubspec.yaml: $FULL_VERSION"
|
||||
|
||||
sed -i "s/^version: .*/version: $FULL_VERSION/" pubspec.yaml || echo_error "Failed to update pubspec.yaml"
|
||||
|
||||
# Génération automatique du fichier AppInfoService (remplace package_info_plus)
|
||||
echo_info "Auto-generating app_info_service.dart with version $VERSION+$BUILD_NUMBER..."
|
||||
cat > lib/core/services/app_info_service.dart <<EOF
|
||||
# Lancer la compilation sur IN1 via SSH
|
||||
echo_info "🚀 Lancement de la compilation sur IN1..."
|
||||
BUILD_START=$(($(date +%s%N)/1000000))
|
||||
|
||||
ssh ${IN1_HOST} "bash -l -s" <<'REMOTE_SCRIPT' || echo_error "Remote build failed on IN1"
|
||||
set -euo pipefail
|
||||
|
||||
# Charger le profil utilisateur pour avoir Flutter dans le PATH
|
||||
if [ -f ~/.bashrc ]; then
|
||||
source ~/.bashrc
|
||||
fi
|
||||
if [ -f ~/.profile ]; then
|
||||
source ~/.profile
|
||||
fi
|
||||
|
||||
cd /home/pierre/dev/geosector/app
|
||||
|
||||
echo "[IN1] Starting Flutter build process..."
|
||||
|
||||
# Charger les variables d'environnement
|
||||
if [ ! -f .env-deploy-dev ]; then
|
||||
echo "ERROR: Missing .env-deploy-dev file"
|
||||
exit 1
|
||||
fi
|
||||
source .env-deploy-dev
|
||||
|
||||
# Lire la version
|
||||
if [ -f ../VERSION ]; then
|
||||
VERSION=$(cat ../VERSION | tr -d '\n\r' | tr -d ' ')
|
||||
echo "[IN1] Version: $VERSION"
|
||||
else
|
||||
echo "ERROR: VERSION file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Génération du build number
|
||||
BUILD_NUMBER=$(echo $VERSION | tr -d '.')
|
||||
FULL_VERSION="${VERSION}+${BUILD_NUMBER}"
|
||||
echo "[IN1] Full version: $FULL_VERSION"
|
||||
|
||||
# Mise à jour du pubspec.yaml
|
||||
sed -i "s/^version: .*/version: $FULL_VERSION/" pubspec.yaml
|
||||
|
||||
# Génération automatique du fichier AppInfoService
|
||||
echo "[IN1] Generating app_info_service.dart..."
|
||||
cat > lib/core/services/app_info_service.dart <<EOF
|
||||
// ⚠️ AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
|
||||
// This file is automatically generated by deploy-app.sh script
|
||||
// Last update: $(date '+%Y-%m-%d %H:%M:%S')
|
||||
@@ -214,53 +278,60 @@ class AppInfoService {
|
||||
static const String packageName = 'fr.geosector.app3';
|
||||
}
|
||||
EOF
|
||||
echo_info "✓ app_info_service.dart updated successfully"
|
||||
|
||||
# Mode de compilation en RELEASE (production)
|
||||
echo_info "🏁 Mode RELEASE - Compilation optimisée pour production"
|
||||
BUILD_FLAGS="--release"
|
||||
# Configuration du cache local
|
||||
echo "[IN1] Configuring local cache..."
|
||||
export PUB_CACHE="$PWD/.pub-cache-local"
|
||||
export GRADLE_USER_HOME="$PWD/.gradle-local"
|
||||
mkdir -p "$PUB_CACHE" "$GRADLE_USER_HOME"
|
||||
|
||||
# Nettoyage
|
||||
echo_info "Cleaning previous builds..."
|
||||
rm -rf .dart_tool build .packages pubspec.lock 2>/dev/null || true
|
||||
flutter clean || echo_warning "Flutter clean partially failed"
|
||||
# Nettoyage
|
||||
echo "[IN1] Cleaning previous builds..."
|
||||
rm -rf .dart_tool build .packages pubspec.lock 2>/dev/null || true
|
||||
flutter clean
|
||||
|
||||
# Build
|
||||
echo_info "Getting dependencies..."
|
||||
flutter pub get || echo_error "Flutter pub get failed"
|
||||
# Build
|
||||
echo "[IN1] Getting dependencies..."
|
||||
flutter pub get
|
||||
|
||||
# Patch nfc_manager 3.3.0 (AndroidManifest namespace)
|
||||
echo_info "Applying nfc_manager 3.3.0 patch..."
|
||||
./fastlane/scripts/commun/fix-nfc-manager.sh || echo_error "nfc_manager patch failed"
|
||||
# Patch nfc_manager 3.3.0
|
||||
echo "[IN1] Applying nfc_manager patch..."
|
||||
./fastlane/scripts/commun/fix-nfc-manager.sh
|
||||
|
||||
echo_info "Cleaning generated files..."
|
||||
dart run build_runner clean || echo_error "Build runner clean failed"
|
||||
echo "[IN1] Cleaning generated files..."
|
||||
dart run build_runner clean
|
||||
|
||||
echo_info "Generating code files..."
|
||||
dart run build_runner build --delete-conflicting-outputs || echo_error "Code generation failed"
|
||||
echo "[IN1] Generating code files..."
|
||||
dart run build_runner build --delete-conflicting-outputs
|
||||
|
||||
echo_info "Building Flutter web application..."
|
||||
# Mesure du temps de compilation Flutter
|
||||
BUILD_START=$(($(date +%s%N)/1000000))
|
||||
echo_info "[$(date '+%H:%M:%S.%3N')] Début de la compilation Flutter (Mode: RELEASE)"
|
||||
# Mode de compilation en RELEASE
|
||||
echo "[IN1] 🏁 Building Flutter web (RELEASE mode)..."
|
||||
flutter build web --release
|
||||
|
||||
flutter build web $BUILD_FLAGS || echo_error "Flutter build failed"
|
||||
echo "[IN1] Fixing web assets structure..."
|
||||
./copy-web-images.sh
|
||||
|
||||
BUILD_END=$(($(date +%s%N)/1000000))
|
||||
BUILD_TIME=$((BUILD_END - BUILD_START))
|
||||
echo_info "[$(date '+%H:%M:%S.%3N')] Fin de la compilation Flutter"
|
||||
echo_info "⏱️ Temps de compilation Flutter: ${BUILD_TIME} ms ($((BUILD_TIME/1000)) secondes)"
|
||||
|
||||
echo_info "Fixing web assets structure..."
|
||||
./copy-web-images.sh || echo_error "Failed to fix web assets"
|
||||
|
||||
# Créer l'archive depuis le build (avec exclusions pour réduire la taille)
|
||||
echo_info "Creating archive from build..."
|
||||
tar -czf "${TEMP_ARCHIVE}" -C ${FLUTTER_BUILD_DIR} \
|
||||
# Créer l'archive sur IN1
|
||||
echo "[IN1] Creating deployment archive..."
|
||||
tar -czf /tmp/app-deploy-build.tar.gz -C build/web \
|
||||
--exclude='*.symbols' \
|
||||
--exclude='*.kra' \
|
||||
--exclude='.DS_Store' \
|
||||
. || echo_error "Failed to create archive"
|
||||
.
|
||||
|
||||
echo "[IN1] Build completed successfully!"
|
||||
REMOTE_SCRIPT
|
||||
|
||||
BUILD_END=$(($(date +%s%N)/1000000))
|
||||
BUILD_TIME=$((BUILD_END - BUILD_START))
|
||||
echo_info "⏱️ Temps de compilation sur IN1: ${BUILD_TIME} ms ($((BUILD_TIME/1000)) secondes)"
|
||||
|
||||
# Récupérer l'archive depuis IN1
|
||||
echo_info "📥 Downloading archive from IN1..."
|
||||
scp ${IN1_HOST}:/tmp/app-deploy-build.tar.gz ${TEMP_ARCHIVE} || echo_error "Failed to download archive from IN1"
|
||||
|
||||
# Nettoyer sur IN1
|
||||
ssh ${IN1_HOST} "rm -f /tmp/app-deploy-build.tar.gz"
|
||||
|
||||
create_local_backup "${TEMP_ARCHIVE}" "dev"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user