Fastlane Github Action Archive Fail with Run Script in Flutter iOS

519 Views Asked by At

I'm currently using fastlane with github action to deploy my Flutter iOS apps to Testflight. I have all the keys and information matched up. However, the build keeps failing at phase Run Script.

`PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-avobjsyvghznfxgtyjuolmxrrfls/Build/Intermediates.noindex/ArchiveIntermediates/prod/IntermediateBuildFilesPath/Runner.build/Release-prod-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh (in target 'Runner' from project 'Runner')`

The fastfile runs fine on my local machine (with the same keys set as ENV) but not on GitHub Action.

The script causing the issue is:

 `/bin/sh "${FLUTTER_ROOT}/packages/flutter_tools/bin/xcode_backend.sh" build` in the **Run Script** phase of Xcode

I tried adding {} around the FLUTTER ROOT but nothing changes.

I added configuration of my Project Runner Info but still same.

The code of my Github Workflow yaml is as followed:

name: Flutter CI

on:
  push:
    branches: xxx

jobs:
  deploy:
    name: Deploying to Testflight
    runs-on: macOS-latest
    
    steps:

      - name: Setup XCode on Machine    
        uses: maxim-lobanov/setup-xcode@v1
        with:
          xcode-version: '13.4'

      - name: Setup Flutter
        uses: subosito/[email protected]
        with:
          channel: 'stable'
          flutter-version: '3.3.9'

      - name: Give permission to private repo
        uses: shaunco/ssh-agent@git-repo-mapping
        with:
          ssh-private-key: |
            ${{ secrets.SECRET_REPO_DEPLOY_KEY }}
          repo-mappings: | 
            github.com/anfin21/package_library

      - name: Checkout repository
        uses: actions/checkout@v1
    
      - name: Install packages
        run: flutter pub get 

      - name: Deploy iOS Beta to TestFlight via Fastlane
        uses: maierj/[email protected]
        with:
          lane: closed_beta
          subdirectory: ios
        env:
          APP_STORE_CONNECT_TEAM_ID: '${{ secrets.ITC_TEAM_ID }}'
          DEVELOPER_APP_ID: '${{ secrets.APPLICATON_ID }}'
          DEVELOPER_APP_IDENTIFIER: '${{ secrets.BUNDLE_IDENTIFIER }}'
          DEVELOPER_PORTAL_TEAM_ID: '${{ secrets.DEVELOPER_PORTAL_TEAM_ID }}'
          FASTLANE_APPLE_ID: '${{ secrets.FASTLANE_APPLE_EMAIL_ID }}'
          FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: '${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}'
          MATCH_PASSWORD: '${{ secrets.MATCH_PASSWORD }}'
          GIT_AUTHORIZATION: '${{ secrets.GIT_AUTHORIZATION }}'
          PROVISIONING_PROFILE_SPECIFIER: '${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}'
          TEMP_KEYCHAIN_PASSWORD: '${{ secrets.TEMP_KEYCHAIN_PASSWORD }}'
          TEMP_KEYCHAIN_USER: '${{ secrets.TEMP_KEYCHAIN_USER }}'
          APPLE_KEY_ID: '${{ secrets.APPLE_KEY_ID }}'
          APPLE_ISSUER_ID: '${{ secrets.APPLE_ISSUER_ID }}'
          APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}'

The FastFile of my iOS is as followed:

default_platform(:ios)
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
DEVELOPER_APP_IDENTIFIER = ENV["DEVELOPER_APP_IDENTIFIER"]
PROVISIONING_PROFILE_SPECIFIER = ENV["PROVISIONING_PROFILE_SPECIFIER"]
TEMP_KEYCHAIN_USER = ENV["TEMP_KEYCHAIN_USER"]
TEMP_KEYCHAIN_PASSWORD = ENV["TEMP_KEYCHAIN_PASSWORD"]
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]

def delete_temp_keychain(name)
  delete_keychain(
    name: name
  ) if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
end

def create_temp_keychain(name, password)
  create_keychain(
    name: name,
    password: password,
    unlock: false,
    timeout: 0
  )
end

def ensure_temp_keychain(name, password)
  delete_temp_keychain(name)
  create_temp_keychain(name, password)
end

platform :ios do

  lane :closed_beta do
    keychain_name = TEMP_KEYCHAIN_USER
    keychain_password = TEMP_KEYCHAIN_PASSWORD
    ensure_temp_keychain(keychain_name, keychain_password)

    
    api_key = app_store_connect_api_key(
      key_id: APPLE_KEY_ID,
      issuer_id: APPLE_ISSUER_ID,
      key_content: APPLE_KEY_CONTENT,            
      duration: 1200,            
      in_house: false
    )

    cocoapods(
      clean_install: true,
    )

    match(
      type: 'appstore',
      app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
      git_basic_authorization: Base64.strict_encode64(GIT_AUTHORIZATION),
      readonly: false,
      keychain_name: keychain_name,
      keychain_password: keychain_password,
      api_key: api_key
    )

    gym(
      configuration: "Release",
      sdk: "iphoneos16.1",
      workspace: "Runner.xcworkspace",
      scheme: "prod",
      export_method: "app-store",
      export_options: {
        provisioningProfiles: { 
            DEVELOPER_APP_ID => PROVISIONING_PROFILE_SPECIFIER
        }
      }
    )

    pilot(
      apple_id: "#{DEVELOPER_APP_ID}",
      app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
      skip_waiting_for_build_processing: true,
      skip_submission: true,
      distribute_external: false,
      notify_external_testers: false,
      ipa: "./Runner.ipa"
    )

    delete_temp_keychain(keychain_name)
  end
end
0

There are 0 best solutions below