From 22aa061013cc78bfc32b41442cf1777e384e5a9b Mon Sep 17 00:00:00 2001 From: Nik Sauer Date: Thu, 10 Oct 2024 10:54:47 +0200 Subject: [PATCH] test-own --- .github/workflows/build-ios.yml | 108 +++++++++++++++++++------------- ios/Podfile | 2 +- 2 files changed, 65 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index 8c7453e..656b932 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -1,4 +1,4 @@ -name: Build iOS App +name: Flutter iOS Build on: push: @@ -7,59 +7,79 @@ on: pull_request: branches: - main - workflow_dispatch: jobs: - build: - name: Build iOS App + build_ios: runs-on: macos-latest + steps: - - name: Checkout Repository - uses: actions/checkout@v4 + # 1. Checkout the repository + - name: Checkout repository + uses: actions/checkout@v3 + + # 2. Install Flutter with subosito/flutter-action@v2 + - name: Install Flutter + uses: subosito/flutter-action@v2 + + # 3. Install dependencies + - name: Install dependencies + run: flutter pub get + + # 4. Set up iOS Signing Keychain and Certificates + - name: Set up iOS Signing Keychain and Certificates + env: + IOS_CERTIFICATE_P12: ${{ secrets.IOS_CERTIFICATE_P12 }} + IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }} + IOS_PROVISIONING_PROFILE: ${{ secrets.IOS_PROVISIONING_PROFILE }} + run: | + # Create a custom keychain + security create-keychain -p "github-actions" ios-build.keychain + security default-keychain -s ios-build.keychain + security unlock-keychain -p "github-actions" ios-build.keychain - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' + # Import the certificate (.p12) + echo $IOS_CERTIFICATE_P12 | base64 --decode > ios_certificate.p12 + security import ios_certificate.p12 -k ios-build.keychain -P $IOS_CERTIFICATE_PASSWORD -T /usr/bin/codesign - - name: Flutter Pub Get - run: flutter pub get + # Set keychain settings + security set-keychain-settings -t 3600 -u ios-build.keychain + security list-keychains -d user -s ios-build.keychain - - name: Install CocoaPods Dependencies - run: | - cd ios - pod install - - name: Set up iOS Signing Keychain and Certificates - env: - IOS_CERTIFICATE_P12: ${{ secrets.IOS_CERTIFICATE_P12 }} - IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }} - IOS_PROVISIONING_PROFILE: ${{ secrets.IOS_PROVISIONING_PROFILE }} - run: | - # Create a custom keychain - security create-keychain -p "github-actions" ios-build.keychain - security default-keychain -s ios-build.keychain - security unlock-keychain -p "github-actions" ios-build.keychain + # Set partition list + security set-key-partition-list -S apple-tool:,apple: -s -k "github-actions" ios-build.keychain - # Import the certificate (.p12) - echo $IOS_CERTIFICATE_P12 | base64 --decode > ios_certificate.p12 - security import ios_certificate.p12 -k ios-build.keychain -P $IOS_CERTIFICATE_PASSWORD -T /usr/bin/codesign + # Install the provisioning profile + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + echo $IOS_PROVISIONING_PROFILE | base64 --decode > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision - # Set keychain settings - security set-keychain-settings -t 3600 -u ios-build.keychain - security list-keychains -d user -s ios-build.keychain + # 5. Ensure Flutter iOS is set up correctly + - name: Flutter doctor (iOS) + run: flutter doctor -v - # Set partition list - security set-key-partition-list -S apple-tool:,apple: -s -k "github-actions" ios-build.keychain + # 6. Build iOS app + - name: Build iOS app for release + run: flutter build ios --release --no-codesign - # Install the provisioning profile - mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles - echo $IOS_PROVISIONING_PROFILE | base64 --decode > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision + # 7. Archive and Export IPA + - name: Archive and Export IPA + run: | + # Archive the app + xcodebuild -workspace ios/Runner.xcworkspace \ + -scheme Runner \ + -sdk iphoneos \ + -configuration Release \ + archive \ + -archivePath build/ios/Runner.xcarchive - - name: Build iOS IPA - run: flutter build ipa --export-options-plist=ios/ExportOptions.plist + # Export the .ipa file + xcodebuild -exportArchive \ + -archivePath build/ios/Runner.xcarchive \ + -exportOptionsPlist ios/Runner/ExportOptions.plist \ + -exportPath build/ios - - name: Upload IPA Artifact - uses: actions/upload-artifact@v4 - with: - name: ios-app - path: build/ios/ipa/*.ipa \ No newline at end of file + # 8. Upload artifact (IPA) for later use + - name: Upload IPA + uses: actions/upload-artifact@v3 + with: + name: iOS-Runner.ipa + path: build/ios/*.ipa diff --git a/ios/Podfile b/ios/Podfile index fac63bd..cba98f6 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '12.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true'