shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
2.19k stars 131 forks source link

docs: instructions for building for iOS with GHA #2336

Open eseidel opened 1 month ago

eseidel commented 1 month ago

Originally posted by @Abdelazeem777 in https://github.com/shorebirdtech/shorebird/issues/1889#issuecomment-2221240888

I am facing the same issue but with github actions

here is my logs:

Run shorebirdtech/shorebird-release@v0
Run shorebird release ios --flutter-version=3.22.2 | tee output.log
⠋ Fetching apps...
✓ Fetching apps (0.2s)
⠋ Building ipa with Flutter 3.22.2 (f32fc7841e)...
✗ Failed to build:
    No Accounts
    No profiles for 'com.taxiapp.rider.taxiAppRider.NotificationService' were found
    No Accounts
    No profiles for 'com.taxiapp.rider.taxiAppRider' were found (846.4s)

If you aren't sure why this command failed, re-run with the --verbose flag to see more information.

You can also ]8;;https://github.com/shorebirdtech/shorebird/issues/new/choose\file an issue]8;;\ if you think this is a bug. Please include the following log file in your report:
/Users/runner/Library/Application Support/shorebird/logs/17206364260[31](https://github.com/Rasan-Al-Arabia/taxi_rider_app/actions/runs/9785778647/job/27019435682#step:11:33)_shorebird.log

Error: Process completed with exit code 70.
eseidel commented 1 month ago

Looks like our instructions at: https://docs.shorebird.dev/ci/github/ are android-only.

It looks like this user is having trouble finding the signing keys on the GHA bot?

It's possible https://docs.shorebird.dev/ci/fastlane/ would help?

Abdelazeem777 commented 1 month ago

Already tried the fastlane solution, but the same issue

Here is a snippet from my action

jobs:
  IOS_BUILD_AND_DISTRIBUTE_TEST_PIPELINE:
    runs-on: macos-latest
    env:
      API_KEY_PATH: ../auth_key.p8
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Copy Apple credentials content from secrets to file
        run: |
          echo "${{ secrets.AUTH_KEY }}" | base64 -D > auth_key.p8

      - name: Install apple certificate
        uses: apple-actions/import-codesign-certs@v2
        with:
          p12-file-base64: ${{ secrets.DIST_CERT_TAXI_PRIVATE_KEY }}
          p12-password: ${{ secrets.DIST_CERT_PASSWORD }}

      - name: Install provisioning profile
        uses: dietdoctor/install-ios-provisioning-profile@latest
        with:
          profile-base64: ${{ secrets.TAXI_RIDER_PROFILE }}

      - name: Install provisioning profile for notification
        uses: dietdoctor/install-ios-provisioning-profile@latest
        with:
          profile-base64: ${{ secrets.TAXI_RIDER_PROFILE_NOTIFICATION }}

      - name: Install cocoapods
        run: sudo gem install cocoapods

      - name: Install Fastlane
        run: gem install fastlane -N --user-install

      - name: Setup Shorebird
        uses: shorebirdtech/setup-shorebird@v1

      - name: Setup configurations before build
        run: |
          cd ios
          fastlane setup_configurations_before_build

      - name: 🚀 Shorebird Release
        uses: shorebirdtech/shorebird-release@v0
        with:
          platform: ios
          args: --flutter-version=3.22.2

And here is my lane

default_platform(:ios)

platform :ios do
  desc "Upload to TestFlight"

  api_key = app_store_connect_api_key(
      key_id: "",
      issuer_id: "",
      key_filepath: ENV["API_KEY_PATH"],
      in_house: false 
    )

  lane :setup_configurations_before_build do   
    increment_build_number(
      build_number: latest_testflight_build_number + 1,
    )

    xcversion(version: "15.3")

    update_code_signing_settings(
      use_automatic_signing: false,
      path: "Runner.xcodeproj",
      team_id: "",
      bundle_identifier: "",
      code_sign_identity: "iPhone Distribution",
      profile_name: "Taxi Rider",
    )

    update_code_signing_settings(
      use_automatic_signing: false,
      path: "Runner.xcodeproj",
      team_id: "",
      bundle_identifier: "",
      code_sign_identity: "iPhone Distribution",
      profile_name: "Taxi Rider Notification",
      targets: ["NotificationService"]
    )

  end

  lane :uploading_to_testflight do
    upload_to_testflight(
      ipa: "../build/ios/ipa/taxi_app_rider.ipa",
      api_key: api_key,
      skip_waiting_for_build_processing: true,
      changelog: "Taxi Rider #{ENV["FLAVOR"]} version",
    )
    end  
end

Note. This pipeline is working fine with the normal build and it can see all profiles and certs.

eseidel commented 1 month ago

Thank you! That's very helpful.

alexmercerind commented 1 month ago

We could release & patch for iOS on GitHub Actions using fastlane, by specifying --export-options-plist in shorebird_release & shorebird_patch (from Shorebird fastlane plugin), after match for syncing certificates & provisioning profiles.

ExportOptions.plist ```xml compileBitcode manageAppVersionAndBuildNumber method app-store provisioningProfiles com.example.yourApp com.example.yourApp's provisioning profile com.example.yourApp.Notification com.example.yourApp.Notification's provisioning profile signingCertificate iOS Distribution signingStyle manual stripSwiftSymbols teamID YOUR_TEAM_ID thinning <none> ```
Fastfile ```ruby default_platform(:ios) platform :ios do lane :release do setup_ci if ENV['CI'] xcversion(version: "15.4") api_key = app_store_connect_api_key( key_id: "YOUR_KEY_ID", issuer_id: "YOUR_ISSUER_ID", key_filepath: "path/to/your/authkey.p8", in_house: false ) match(type: "appstore") match(type: "appstore", app_identifier: "com.example.yourApp.Notification") # https://docs.shorebird.dev/ci/fastlane shorebird_release( platform: "ios", args: "--build-name=#{ENV['NEXT_BUILD_NAME']} --build-number=#{ENV['NEXT_BUILD_NUMBER']} --export-options-plist=#{ENV['EXPORT_OPTIONS_PLIST']} --flutter-version=#{ENV['FLUTTER_VERSION']}" ) pilot( api_key: api_key, skip_submission: true, skip_waiting_for_build_processing: true, ipa: "../build/ios/ipa/your_app.ipa" ) end lane :patch do setup_ci if ENV['CI'] xcversion(version: "15.4") api_key = app_store_connect_api_key( key_id: "YOUR_KEY_ID", issuer_id: "YOUR_ISSUER_ID", key_filepath: "path/to/your/authkey.p8", in_house: false ) match(type: "appstore") match(type: "appstore", app_identifier: "com.example.yourApp.Notification") # https://docs.shorebird.dev/ci/fastlane shorebird_patch( platform: "ios", args: "--build-name=#{ENV['TARGET_BUILD_NAME']} --build-number=#{ENV['TARGET_BUILD_NUMBER']} --release-version=#{ENV['TARGET_BUILD_NAME']}+#{ENV['TARGET_BUILD_NUMBER']} --export-options-plist=#{ENV['EXPORT_OPTIONS_PLIST']}" ) end end ```

Thanks!

zheldRnaskan commented 4 days ago

@alexmercerind Unfortunately your suggestion didn't worked for me. when I add "export-options-plist" args to shorebird_release, it couldn't build the app.