1# Prevent Fastlane from overwriting README.md 2skip_docs 3 4default_platform(:ios) 5 6def suppress_output 7 original_stdout, original_stderr = $stdout.clone, $stderr.clone 8 $stderr.reopen File.new('/dev/null', 'w') 9 $stdout.reopen File.new('/dev/null', 'w') 10 yield 11ensure 12 $stdout.reopen original_stdout 13 $stderr.reopen original_stderr 14end 15 16# This should be run after running 17# flutter build ios --release --no-codesign 18# to build the app using the Flutter toolchain. This lane is meant to only 19# rebuild the app by: 20# 1- Signing using the publishing credentials; and 21# 2- xcodebuild with archive option 22platform :ios do 23 desc 'Push a new release to TestFlight' 24 lane :build_and_deploy_testflight do |options| 25 # Doesn't do anything when not on a CI bot. Even though it's called 26 # "setup_travis", this also runs on Cirrus, since the CI environment 27 # variable is set. When on a CI bot, it creates a temporary keychain and 28 # switches "match" to readonly mode to not create new profiles/certs on CI. 29 setup_travis 30 31 # Relative to this file. 32 raw_version = File.read('../../../../version') 33 puts "Building and deploying version #{raw_version}..." 34 35 update_app_identifier( 36 plist_path: 'Runner/Info.plist', 37 # Let the checked-in bundle ID be different so users don't collide on 38 # provisioning profile creation when building locally. 39 app_identifier: 'io.flutter.demo.gallery' 40 ) 41 42 increment_version_number( 43 # Only major, minor, patch digits and dots. 44 version_number: /\d+\.\d+\.\d+/.match(raw_version)[0] 45 ) 46 47 # Stop fastlane from echoing back PUBLISHING_MATCH_CERTIFICATE_REPO var. 48 # Doesn't matter too much since Cirrus doesn't echo back encrypted variables 49 # anyway. 50 suppress_output { 51 # Retrieves all the necessary certs and provisioning profiles. 52 sync_code_signing( 53 git_url: "https://x-access-token:#{ENV['PUBLISHING_MATCH_REPO_TOKEN']}@#{ENV['PUBLISHING_MATCH_CERTIFICATE_REPO']}" , 54 type: 'appstore', 55 readonly: true, 56 ) 57 } 58 puts 'Certificates and profiles installed' 59 60 # Modify the Xcode project to use the new team and profile. 61 # It will put the git state to dirty but Travis will be wiped after 62 # then run session. 63 disable_automatic_code_signing 64 update_project_provisioning( 65 xcodeproj: 'Runner.xcodeproj', 66 target_filter: 'Runner', 67 build_configuration: 'Release', 68 profile: ENV['sigh_io.flutter.demo.gallery_appstore_profile-path'], 69 ) 70 71 # Build and archive the app again. 72 build_ios_app( 73 workspace: 'Runner.xcworkspace', 74 scheme: 'Runner', 75 export_method: 'app-store', 76 # Verify that the right signing identity is used for publishing. 77 codesigning_identity: 'iPhone Distribution: FLUTTER.IO LLC (S8QB4VV633)', 78 ) 79 80 if options[:upload] 81 upload_to_testflight 82 end 83 end 84end 85