diff --git a/.github/workflows/deploy-playstore.yml b/.github/workflows/deploy-playstore.yml deleted file mode 100644 index 4c43ed1..0000000 --- a/.github/workflows/deploy-playstore.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Deploy to Play Store - -on: - push: - branches: - - release # L'action se déclenche uniquement sur la branche 'release' - -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - # 1. Récupérer le code - - uses: actions/checkout@v4 - - # 2. Installer Java (requis pour Android build) - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - - # 3. Installer Flutter - - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - # 4. Gérer les dépendances - - run: flutter pub get - - # 5. Créer le Keystore depuis le secret (Décodage) - - name: Decode Keystore - run: | - echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > android/app/upload-keystore.jks - - # 6. Créer le fichier key.properties pour que Gradle trouve la clé - - name: Create key.properties - run: | - echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" > android/key.properties - echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties - echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties - echo "storeFile=upload-keystore.jks" >> android/key.properties - - # 7. Construire l'AppBundle (.aab) - - name: Build AppBundle - run: flutter build appbundle --release - - # 8. Uploader sur le Play Store (Track: alpha = Test fermé) - - name: Upload to Play Store - uses: r0adkll/upload-google-play@v1 - with: - serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_CONFIG_JSON }} - packageName: be.devdayronvl.travel_mate - releaseFiles: build/app/outputs/bundle/release/app-release.aab - track: alpha # 'alpha' correspond souvent au Test Fermé. Sinon 'internal' ou 'beta'. - status: completed \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..184dfe6 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,64 @@ +pipeline { + agent any + + environment { + // On pointe vers le dossier SDK qu'on a installé dans le HOME de l'utilisateur jenkins + ANDROID_HOME = "${env.HOME}/android-sdk" + // On ajoute Flutter et les outils Android au PATH pour cette session + PATH = "/opt/flutter/bin:${env.HOME}/android-sdk/cmdline-tools/latest/bin:${env.HOME}/android-sdk/platform-tools:$PATH" + + // On récupère vos secrets stockés dans Jenkins + STORE_PASS = credentials('android-store-pass') + KEY_PASS = credentials('android-key-pass') + } + + stages { + stage('Checkout') { + steps { + // Récupère le code depuis Gitea + checkout scm + } + } + + stage('Setup Dependencies') { + steps { + sh 'flutter config --no-analytics' + sh 'flutter pub get' + } + } + + stage('Build & Deploy Android') { + steps { + // On injecte les fichiers secrets temporairement + withCredentials([ + file(credentialsId: 'android-keystore-file', variable: 'KEYSTORE_PATH'), + file(credentialsId: 'google-play-json', variable: 'GOOGLE_JSON') + ]) { + script { + // 1. Créer le fichier key.properties pour Gradle + // Note : Assurez-vous que votre 'keyAlias' est bien 'key0' (défaut) ou changez-le ici + sh """ + echo 'storePassword=$STORE_PASS' > android/key.properties + echo 'keyPassword=$KEY_PASS' >> android/key.properties + echo 'keyAlias=upload' >> android/key.properties + echo 'storeFile=$KEYSTORE_PATH' >> android/key.properties + """ + + // 2. Lancer Fastlane + dir('android') { + // On passe le chemin du JSON via une variable d'environnement à Fastlane + sh "GOOGLE_JSON_KEY_PATH='$GOOGLE_JSON' fastlane deploy_internal" + } + } + } + } + } + } + + post { + always { + // Sécurité : On supprime le fichier contenant les mots de passe + sh 'rm -f android/key.properties' + } + } +} \ No newline at end of file diff --git a/android/Gemfile b/android/Gemfile new file mode 100644 index 0000000..7a118b4 --- /dev/null +++ b/android/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "fastlane" diff --git a/android/fastlane/Appfile b/android/fastlane/Appfile new file mode 100644 index 0000000..74f9886 --- /dev/null +++ b/android/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file(ENV["GOOGLE_PLAY_JSON_KEY_FILE"]) # Path to the json secret file - defined in Jenkins +package_name("be.devdayronvl.travel_mate") # Your package name diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile new file mode 100644 index 0000000..74cbc6e --- /dev/null +++ b/android/fastlane/Fastfile @@ -0,0 +1,16 @@ +default_platform(:android) + +platform :android do + desc "Deploy to Internal Testing" + lane :deploy_internal do + # Build de l'application + sh "cd ../.. && flutter build appbundle --release" + + # Upload vers Google Play + upload_to_play_store( + track: 'internal', # 'internal' = Test interne, 'alpha' = Test fermé + aab: '../build/app/outputs/bundle/release/app-release.aab', + json_key: ENV['GOOGLE_JSON_KEY_PATH'] # Jenkins remplit cette variable magiquement + ) + end +end \ No newline at end of file