[FIX] Provisioning profile UUID 추출 방법 개선 및 ExportOptions에 signing 설정 추가 #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Develop Build & Deploy | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| jobs: | |
| build-android-dev: | |
| name: Build Android Dev | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.24.5' | |
| channel: 'stable' | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build Android APK (Dev) | |
| run: | | |
| flutter build apk --release \ | |
| --build-name=1.0.0-dev \ | |
| --build-number=${{ github.run_number }} \ | |
| --dart-define=API_ENV=dev | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-dev-apk | |
| path: build/app/outputs/flutter-apk/app-release.apk | |
| retention-days: 30 | |
| build-ios-dev: | |
| name: Build iOS Dev | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.24.5' | |
| channel: 'stable' | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Install CocoaPods dependencies | |
| run: | | |
| cd ios | |
| pod install | |
| - name: Setup iOS Certificates and Profiles | |
| env: | |
| APPLE_CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }} | |
| APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| APPLE_PROVISIONING_PROFILE_BASE64: ${{ secrets.APPLE_PROVISIONING_PROFILE_BASE64 }} | |
| run: | | |
| # Certificate와 비밀번호가 모두 제공된 경우에만 설정 시도 | |
| if [ -n "$APPLE_CERTIFICATE_BASE64" ] && [ -n "$APPLE_CERTIFICATE_PASSWORD" ]; then | |
| # Create keychain | |
| security create-keychain -p "" build.keychain || true | |
| security default-keychain -s build.keychain || true | |
| security unlock-keychain -p "" build.keychain || true | |
| security set-keychain-settings -t 3600 -u build.keychain || true | |
| # Import certificate | |
| echo "$APPLE_CERTIFICATE_BASE64" | base64 -d > certificate.p12 | |
| if ! security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign; then | |
| echo "Certificate import failed. Will continue with provisioning profile setup." | |
| fi | |
| # Import provisioning profile (if provided) | |
| if [ -n "$APPLE_PROVISIONING_PROFILE_BASE64" ]; then | |
| echo "$APPLE_PROVISIONING_PROFILE_BASE64" | base64 -d > profile.mobileprovision | |
| # Extract UUID from provisioning profile using multiple methods | |
| PROFILE_UUID="" | |
| # Method 1: Using security cms and plutil | |
| if command -v plutil &> /dev/null; then | |
| PROFILE_UUID=$(security cms -D -i profile.mobileprovision 2>/dev/null | plutil -extract UUID raw -o - - 2>/dev/null) | |
| fi | |
| # Method 2: Using grep and sed as fallback | |
| if [ -z "$PROFILE_UUID" ]; then | |
| PROFILE_UUID=$(security cms -D -i profile.mobileprovision 2>/dev/null | grep -A1 "<key>UUID</key>" | grep -o "<string>.*</string>" | sed 's/<string>\(.*\)<\/string>/\1/' | head -1) | |
| fi | |
| # Method 3: Using PlistBuddy | |
| if [ -z "$PROFILE_UUID" ]; then | |
| TEMP_PLIST=$(mktemp) | |
| security cms -D -i profile.mobileprovision > "$TEMP_PLIST" 2>/dev/null | |
| PROFILE_UUID=$(/usr/libexec/PlistBuddy -c "Print UUID" "$TEMP_PLIST" 2>/dev/null) | |
| rm -f "$TEMP_PLIST" | |
| fi | |
| # Install provisioning profile | |
| mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
| if [ -n "$PROFILE_UUID" ]; then | |
| cp profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$PROFILE_UUID.mobileprovision | |
| echo "✅ Provisioning profile installed as: $PROFILE_UUID.mobileprovision" | |
| echo "Profile UUID: $PROFILE_UUID" | |
| else | |
| # Fallback: Use a generic name | |
| cp profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision | |
| echo "⚠️ Provisioning profile installed with generic name (UUID extraction failed)" | |
| echo "Trying to list installed profiles..." | |
| ls -la ~/Library/MobileDevice/Provisioning\ Profiles/ || true | |
| fi | |
| # Verify profile installation | |
| echo "Installed profiles:" | |
| ls -la ~/Library/MobileDevice/Provisioning\ Profiles/ | grep -i mobileprovision || echo "No profiles found" | |
| fi | |
| # Set keychain to allow codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" build.keychain || true | |
| else | |
| echo "No certificate provided. Will use automatic signing." | |
| fi | |
| - name: Build iOS IPA (Dev) | |
| run: | | |
| flutter build ipa --release \ | |
| --build-name=1.0.0-dev \ | |
| --build-number=${{ github.run_number }} \ | |
| --dart-define=API_ENV=dev \ | |
| --export-options-plist=ios/ExportOptions-dev.plist | |
| - name: Upload IPA artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ios-dev-ipa | |
| path: build/ios/ipa/*.ipa | |
| retention-days: 30 | |
| - name: Upload to TestFlight (Dev) | |
| if: success() | |
| env: | |
| APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} | |
| APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} | |
| APP_STORE_CONNECT_API_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY }} | |
| run: | | |
| # Create API key file | |
| mkdir -p ~/private_keys | |
| echo "$APP_STORE_CONNECT_API_KEY" > ~/private_keys/AuthKey_$APP_STORE_CONNECT_API_KEY_ID.p8 | |
| chmod 600 ~/private_keys/AuthKey_$APP_STORE_CONNECT_API_KEY_ID.p8 | |
| # Upload using xcrun altool | |
| xcrun altool --upload-app \ | |
| --type ios \ | |
| --file build/ios/ipa/*.ipa \ | |
| --apiKey $APP_STORE_CONNECT_API_KEY_ID \ | |
| --apiIssuer $APP_STORE_CONNECT_ISSUER_ID \ | |
| --verbose | |