229 lines
9.1 KiB
YAML
229 lines
9.1 KiB
YAML
name: Deploy TravelMate (Full Mobile)
|
|
on:
|
|
push:
|
|
branches:
|
|
- release
|
|
|
|
jobs:
|
|
# --- JOB 1 : ANDROID (Génération APK) ---
|
|
deploy-android:
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Configuration Flutter & Secrets
|
|
run: |
|
|
flutter pub get
|
|
echo "${{ secrets.ENV_FILE }}" > .env
|
|
printf '%s' '${{ secrets.FIREBASE_CREDENTIALS }}' > ./android/firebase_credentials.json
|
|
|
|
- name: Build & Deploy Android
|
|
working-directory: ./android
|
|
env:
|
|
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
|
RAW_PROPERTIES: ${{ secrets.ANDROID_KEY_PROPERTIES }}
|
|
FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }}
|
|
run: |
|
|
# 1. Keystore
|
|
echo "$ANDROID_KEYSTORE_BASE64" | base64 -D > keystore.jks
|
|
echo "$RAW_PROPERTIES" > temp_props.txt
|
|
echo "storePassword=$(grep 'storePassword' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" > key.properties
|
|
echo "keyPassword=$(grep 'keyPassword' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" >> key.properties
|
|
echo "keyAlias=$(grep 'keyAlias' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" >> key.properties
|
|
echo "storeFile=$(pwd)/keystore.jks" >> key.properties
|
|
|
|
# 2. Gemfile (Correctifs Ruby 3.4 inclus)
|
|
echo "source 'https://rubygems.org'" > Gemfile
|
|
echo "gem 'fastlane', '>= 2.230.0'" >> Gemfile
|
|
echo "gem 'fastlane-plugin-firebase_app_distribution'" >> Gemfile
|
|
for g in abbrev ostruct mutex_m base64 csv bigdecimal drb nkf reline logger; do echo "gem '$g'" >> Gemfile; done
|
|
|
|
gem install bundler -v 2.7.2 --no-document
|
|
bundle _2.7.2_ update
|
|
|
|
# 3. Build & Envoi
|
|
cd .. && flutter build apk --release && cd android
|
|
bundle _2.7.2_ exec fastlane run firebase_app_distribution \
|
|
app:"$FIREBASE_ANDROID_APP_ID" \
|
|
android_artifact_path:"../build/app/outputs/flutter-apk/app-release.apk" \
|
|
service_credentials_file:"firebase_credentials.json"
|
|
|
|
# --- JOB 2 : IOS (Génération IPA) ---
|
|
deploy-ios:
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Dépendances iOS & Secrets
|
|
run: |
|
|
flutter pub get
|
|
echo "${{ secrets.ENV_FILE }}" > .env
|
|
printf '%s' '${{ secrets.FIREBASE_CREDENTIALS }}' > ./ios/firebase_credentials.json
|
|
cd ios && (pod install --repo-update || pod update)
|
|
|
|
- name: Préparer le Code Signing
|
|
env:
|
|
P12_BASE: ${{ secrets.IOS_P12_BASE64 }}
|
|
P12_PASS: ${{ secrets.IOS_P12_PASSWORD }}
|
|
PROV_BASE: ${{ secrets.IOS_PROVISION_BASE64 }}
|
|
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
|
run: |
|
|
# Créer et configurer le keychain
|
|
security delete-keychain build.keychain || true
|
|
security create-keychain -p "" build.keychain
|
|
security unlock-keychain -p "" build.keychain
|
|
security list-keychains -d user -s build.keychain $(security list-keychains -d user | xargs)
|
|
security set-keychain-settings -lut 21600 build.keychain
|
|
|
|
# Importer le certificat
|
|
echo "$P12_BASE" | base64 -D -o cert.p12
|
|
security import cert.p12 -k build.keychain -P "$P12_PASS" -T /usr/bin/codesign
|
|
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
|
|
|
|
# Installer le profil de provisioning
|
|
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
|
|
PROFILE_PATH=~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision
|
|
echo "$PROV_BASE" | base64 -D -o "$PROFILE_PATH"
|
|
|
|
# Extraire l'UUID du profil
|
|
PROFILE_UUID=$(/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i "$PROFILE_PATH"))
|
|
echo "Profile UUID: $PROFILE_UUID"
|
|
|
|
# Copier avec l'UUID correct
|
|
cp "$PROFILE_PATH" ~/Library/MobileDevice/Provisioning\ Profiles/$PROFILE_UUID.mobileprovision
|
|
|
|
- name: Configurer le projet Xcode
|
|
env:
|
|
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
|
BUNDLE_ID: ${{ secrets.IOS_BUNDLE_ID }}
|
|
run: |
|
|
cd ios
|
|
|
|
# Extraire le nom du profil de provisioning
|
|
PROV_NAME=$(/usr/libexec/PlistBuddy -c "Print Name" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
|
echo "Provisioning Profile Name: $PROV_NAME"
|
|
|
|
# Configurer le projet avec xcconfig
|
|
cat > build_config.xcconfig <<EOF
|
|
DEVELOPMENT_TEAM = $TEAM_ID
|
|
CODE_SIGN_STYLE = Manual
|
|
CODE_SIGN_IDENTITY = Apple Distribution
|
|
PROVISIONING_PROFILE_SPECIFIER = $PROV_NAME
|
|
PRODUCT_BUNDLE_IDENTIFIER = $BUNDLE_ID
|
|
EOF
|
|
|
|
echo "Configuration créée avec succès"
|
|
|
|
- name: Créer exportOptions.plist
|
|
env:
|
|
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
|
BUNDLE_ID: ${{ secrets.IOS_BUNDLE_ID }}
|
|
run: |
|
|
# Extraire le nom du profil
|
|
PROV_NAME=$(/usr/libexec/PlistBuddy -c "Print Name" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
|
|
|
cat > ios/exportOptions.plist <<EOF
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>method</key>
|
|
<string>ad-hoc</string>
|
|
<key>teamID</key>
|
|
<string>$TEAM_ID</string>
|
|
<key>signingStyle</key>
|
|
<string>manual</string>
|
|
<key>provisioningProfiles</key>
|
|
<dict>
|
|
<key>$BUNDLE_ID</key>
|
|
<string>$PROV_NAME</string>
|
|
</dict>
|
|
</dict>
|
|
</plist>
|
|
EOF
|
|
|
|
- name: Build avec xcodebuild
|
|
env:
|
|
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
|
run: |
|
|
cd ios
|
|
|
|
# Extraire le nom du profil
|
|
PROV_NAME=$(/usr/libexec/PlistBuddy -c "Print Name" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
|
|
|
# Clean et build avec Flutter
|
|
cd ..
|
|
flutter clean
|
|
flutter pub get
|
|
flutter build ios --release --no-codesign
|
|
|
|
# Créer le dossier de sortie
|
|
mkdir -p build/ios/ipa
|
|
|
|
# Archive avec xcodebuild
|
|
cd ios
|
|
xcodebuild -workspace Runner.xcworkspace \
|
|
-scheme Runner \
|
|
-configuration Release \
|
|
-archivePath ../build/ios/Runner.xcarchive \
|
|
-xcconfig build_config.xcconfig \
|
|
archive \
|
|
CODE_SIGN_STYLE=Manual \
|
|
CODE_SIGN_IDENTITY="Apple Distribution" \
|
|
PROVISIONING_PROFILE_SPECIFIER="$PROV_NAME" \
|
|
DEVELOPMENT_TEAM="$TEAM_ID" \
|
|
| xcpretty || true
|
|
|
|
# Export en IPA
|
|
xcodebuild -exportArchive \
|
|
-archivePath ../build/ios/Runner.xcarchive \
|
|
-exportPath ../build/ios/ipa \
|
|
-exportOptionsPlist exportOptions.plist \
|
|
-allowProvisioningUpdates \
|
|
| xcpretty || true
|
|
|
|
cd ..
|
|
echo "📦 Contenu du dossier IPA :"
|
|
ls -lah build/ios/ipa/ || echo "Dossier IPA non trouvé"
|
|
|
|
- name: Vérification et Upload Firebase
|
|
env:
|
|
FIREBASE_IOS_APP_ID: ${{ secrets.FIREBASE_IOS_APP_ID }}
|
|
run: |
|
|
cd ios
|
|
|
|
# Configuration Fastlane
|
|
echo "source 'https://rubygems.org'" > Gemfile
|
|
echo "gem 'fastlane', '>= 2.230.0'" >> Gemfile
|
|
echo "gem 'fastlane-plugin-firebase_app_distribution'" >> Gemfile
|
|
for g in abbrev ostruct mutex_m base64 csv bigdecimal drb nkf reline logger; do echo "gem '$g'" >> Gemfile; done
|
|
|
|
gem install bundler -v 2.7.2 --no-document
|
|
bundle _2.7.2_ update
|
|
|
|
# Recherche de l'IPA
|
|
IPA_FILE=$(find ../build/ios/ipa -name "*.ipa" | head -n 1)
|
|
|
|
if [ -z "$IPA_FILE" ]; then
|
|
echo "❌ ERREUR : Aucun fichier IPA trouvé !"
|
|
echo "📂 Structure complète du dossier build :"
|
|
ls -R ../build/
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ IPA trouvée : $IPA_FILE"
|
|
echo "📊 Taille : $(du -h "$IPA_FILE" | cut -f1)"
|
|
|
|
# Upload vers Firebase
|
|
bundle _2.7.2_ exec fastlane run firebase_app_distribution \
|
|
app:"$FIREBASE_IOS_APP_ID" \
|
|
ipa_path:"$IPA_FILE" \
|
|
service_credentials_file:"firebase_credentials.json"
|
|
|
|
- name: Nettoyage Final
|
|
if: always()
|
|
run: |
|
|
security list-keychains -d user -s login.keychain
|
|
security delete-keychain build.keychain || true |