|
1 | | -default_platform(:ios) |
2 | 1 | skip_docs |
3 | 2 |
|
| 3 | +# Common Configuration |
4 | 4 | github_repo = ENV['GITHUB_REPOSITORY'] || 'GetStream/stream-chat-react-native' |
5 | | -bundle_id = 'io.getstream.reactnative.SampleApp' |
6 | | -xcode_project = 'ios/SampleApp.xcodeproj' |
7 | | -xcode_workspace = 'ios/SampleApp.xcworkspace' |
8 | 5 | root_path = File.absolute_path('../../../') |
9 | 6 | sdk_size_ext = 'KB' |
10 | 7 | @force_check = false |
| 8 | +build_output_directory = "./app-build" |
| 9 | + |
| 10 | +# iOS Platform Configuration |
| 11 | +bundle_id = 'io.getstream.reactnative.SampleApp' |
| 12 | +xcode_project = 'ios/SampleApp.xcodeproj' |
| 13 | +xcode_workspace = 'ios/SampleApp.xcworkspace' |
| 14 | +output_ipa_name = "reactnativesampleapp.ipa" |
| 15 | + |
| 16 | +# Android Platform Configuration |
| 17 | +package_name = 'io.getstream.reactnative.sampleapp' |
| 18 | +firebase_app_id = "1:860064972837:android:45442c1123323ac9f17fcc" |
| 19 | +firebase_credentials_file = "./credentials/firebase-credentials.json" |
| 20 | +output_apk_name = "reactnativesampleapp.apk" |
| 21 | +apk_path = "#{build_output_directory}/#{output_apk_name}" |
| 22 | + |
11 | 23 |
|
12 | 24 | before_all do |
13 | 25 | if is_ci |
|
20 | 32 | ###### iOS lanes ###### |
21 | 33 | ####################### |
22 | 34 |
|
23 | | -lane :deploy_to_testflight_qa do |options| |
24 | | - match_me |
25 | | - |
26 | | - settings_to_override = { |
27 | | - BUNDLE_IDENTIFIER: bundle_id, |
28 | | - PROVISIONING_PROFILE_SPECIFIER: "match AppStore #{bundle_id}" |
29 | | - } |
30 | | - |
31 | | - increment_version_number( |
32 | | - version_number: load_json(json_path: './package.json')['version'], |
33 | | - xcodeproj: xcode_project |
34 | | - ) |
35 | | - |
36 | | - current_build_number = app_store_build_number( |
37 | | - api_key: appstore_api_key, |
38 | | - live: false, |
39 | | - app_identifier: bundle_id |
| 35 | +platform :ios do |
| 36 | + lane :deploy_to_testflight_qa do |options| |
| 37 | + match_me |
| 38 | + |
| 39 | + deploy = options.fetch(:deploy, false) |
| 40 | + |
| 41 | + UI.message("Deploying to Testflight: #{deploy}") |
| 42 | + |
| 43 | + settings_to_override = { |
| 44 | + BUNDLE_IDENTIFIER: bundle_id, |
| 45 | + PROVISIONING_PROFILE_SPECIFIER: "match AppStore #{bundle_id}" |
| 46 | + } |
| 47 | + |
| 48 | + gym( |
| 49 | + workspace: xcode_workspace, |
| 50 | + scheme: 'SampleApp', |
| 51 | + export_method: 'app-store', |
| 52 | + export_options: './fastlane/testflight_gym_export_options.plist', |
| 53 | + silent: true, |
| 54 | + clean: true, |
| 55 | + xcargs: settings_to_override, |
| 56 | + include_symbols: true, |
| 57 | + output_directory: build_output_directory |
40 | 58 | ) |
41 | 59 |
|
42 | | - increment_build_number( |
43 | | - build_number: current_build_number + 1, |
44 | | - xcodeproj: xcode_project |
45 | | - ) |
| 60 | + if deploy |
| 61 | + increment_version_number( |
| 62 | + version_number: load_json(json_path: './package.json')['version'], |
| 63 | + xcodeproj: xcode_project |
| 64 | + ) |
46 | 65 |
|
47 | | - gym( |
48 | | - workspace: xcode_workspace, |
49 | | - scheme: 'SampleApp', |
50 | | - export_method: 'app-store', |
51 | | - export_options: './fastlane/testflight_gym_export_options.plist', |
52 | | - silent: true, |
53 | | - clean: true, |
54 | | - xcargs: settings_to_override, |
55 | | - include_symbols: true, |
56 | | - output_directory: './dist' |
57 | | - ) |
| 66 | + current_build_number = app_store_build_number( |
| 67 | + api_key: appstore_api_key, |
| 68 | + live: false, |
| 69 | + app_identifier: bundle_id |
| 70 | + ) |
| 71 | + |
| 72 | + increment_build_number( |
| 73 | + build_number: current_build_number + 1, |
| 74 | + xcodeproj: xcode_project |
| 75 | + ) |
58 | 76 |
|
59 | | - if options[:deploy] |
60 | | - begin |
61 | 77 | upload_to_testflight( |
62 | 78 | groups: ['Testers'], |
63 | 79 | changelog: 'Lots of amazing new features to test out!', |
64 | | - reject_build_waiting_for_review: false |
| 80 | + reject_build_waiting_for_review: false, |
| 81 | + ipa: "#{build_output_directory}/#{output_ipa_name}" |
65 | 82 | ) |
66 | | - rescue StandardError => e |
67 | | - if e.message.include?('Another build is in review') |
68 | | - UI.important('Another build is already in beta review. Skipping beta review submission') |
69 | | - else |
70 | | - UI.user_error!(e) |
71 | | - end |
| 83 | + else |
| 84 | + UI.message("Skipping Testflight upload! (deploy: #{deploy})") |
72 | 85 | end |
73 | 86 | end |
74 | | -end |
75 | | - |
76 | | -private_lane :appstore_api_key do |
77 | | - @appstore_api_key ||= app_store_connect_api_key( |
78 | | - key_id: 'MT3PRT8TB7', |
79 | | - issuer_id: '69a6de96-0738-47e3-e053-5b8c7c11a4d1', |
80 | | - key_content: ENV.fetch('APPSTORE_API_KEY', nil), |
81 | | - in_house: false |
82 | | - ) |
83 | | -end |
84 | 87 |
|
85 | | -desc "If `readonly: true` (by default), installs all Certs and Profiles necessary for development and ad-hoc.\nIf `readonly: false`, recreates all Profiles necessary for development and ad-hoc, updates them locally and remotely." |
86 | | -lane :match_me do |options| |
87 | | - custom_match( |
88 | | - api_key: appstore_api_key, |
89 | | - app_identifier: [bundle_id], |
90 | | - readonly: options[:readonly], |
91 | | - register_device: options[:register_device] |
92 | | - ) |
| 88 | + private_lane :appstore_api_key do |
| 89 | + @appstore_api_key ||= app_store_connect_api_key( |
| 90 | + key_id: 'MT3PRT8TB7', |
| 91 | + issuer_id: '69a6de96-0738-47e3-e053-5b8c7c11a4d1', |
| 92 | + key_content: ENV.fetch('APPSTORE_API_KEY', nil), |
| 93 | + in_house: false |
| 94 | + ) |
| 95 | + end |
| 96 | + |
| 97 | + desc "If `readonly: true` (by default), installs all Certs and Profiles necessary for development and ad-hoc.\nIf `readonly: false`, recreates all Profiles necessary for development and ad-hoc, updates them locally and remotely." |
| 98 | + lane :match_me do |options| |
| 99 | + custom_match( |
| 100 | + api_key: appstore_api_key, |
| 101 | + app_identifier: [bundle_id], |
| 102 | + readonly: options[:readonly], |
| 103 | + register_device: options[:register_device] |
| 104 | + ) |
| 105 | + end |
93 | 106 | end |
94 | 107 |
|
95 | 108 | ########################### |
96 | 109 | ###### Android lanes ###### |
97 | 110 | ########################### |
98 | 111 |
|
| 112 | +platform :android do |
| 113 | + lane :firebase_build_and_upload do |options| |
| 114 | + deploy = options.fetch(:deploy, false) |
| 115 | + |
| 116 | + UI.message("Deploying to Firebase: #{deploy}") |
| 117 | + |
| 118 | + # Clean |
| 119 | + gradle( |
| 120 | + task: "clean", |
| 121 | + project_dir: "./android" |
| 122 | + ) |
| 123 | + |
| 124 | + # Build the AAB |
| 125 | + gradle( |
| 126 | + task: "assemble", |
| 127 | + build_type: "Release", |
| 128 | + project_dir: "./android" |
| 129 | + ) |
| 130 | + |
| 131 | + Dir.chdir('..') do |
| 132 | + sh("mkdir -p #{build_output_directory} && mv -f #{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]} #{apk_path}") |
| 133 | + end |
| 134 | + |
| 135 | + if deploy |
| 136 | + latest_app_distribution_release = firebase_app_distribution_get_latest_release( |
| 137 | + app: firebase_app_id, |
| 138 | + service_credentials_file: firebase_credentials_file |
| 139 | + ) |
| 140 | + |
| 141 | + # Handle case when no previous releases exist |
| 142 | + if latest_app_distribution_release.nil? || latest_app_distribution_release.empty? |
| 143 | + puts "No previous releases found. Starting with version code 1" |
| 144 | + latest_app_distribution_version_code = 0 # Will be incremented to 1 |
| 145 | + else |
| 146 | + latest_app_distribution_version_code = latest_app_distribution_release[:buildVersion].to_i |
| 147 | + puts "Latest version code from App Distribution: #{latest_app_distribution_version_code}" |
| 148 | + end |
| 149 | + |
| 150 | + increment_version_code( |
| 151 | + gradle_file_path: "./android/app/build.gradle", |
| 152 | + version_code: latest_app_distribution_version_code + 1 |
| 153 | + ) |
| 154 | + |
| 155 | + # Upload to Firebase App Distribution |
| 156 | + firebase_app_distribution( |
| 157 | + app: firebase_app_id, |
| 158 | + service_credentials_file: firebase_credentials_file, |
| 159 | + android_artifact_path: apk_path, |
| 160 | + android_artifact_type: "APK", |
| 161 | + groups: "stream-testers" |
| 162 | + ) |
| 163 | + else |
| 164 | + UI.message("Skipping Firebase upload! (deploy: #{deploy})") |
| 165 | + end |
| 166 | + end |
| 167 | +end |
| 168 | + |
99 | 169 | ########################## |
100 | 170 | ###### Common lanes ###### |
101 | 171 | ########################## |
|
0 commit comments