|
1 | | -# If you want to automatically update fastlane if a new version is available: |
2 | | -#update_fastlane |
3 | | - |
4 | | -# This is the minimum version number required. |
5 | | -# Update this, if you use features of a newer version |
6 | | -fastlane_version "2.213.0" |
7 | | - |
8 | | -default_platform :ios |
9 | | - |
10 | 1 | # Constants |
11 | 2 | APPLE_STORE_VERSION = sh("node -p -e \"require('../../package.json')['store-versions']['apple-store']\"").chomp |
12 | | -BUILD_NUMBER = 1 |
13 | | -ORIGINAL_CHANGELOG_PATH = "../../CHANGELOG.ios.txt" |
14 | | -FASTLANE_CHANGELOG_PATH = "./metadata/default/release_notes.txt" |
15 | 3 |
|
16 | | -platform :ios do |
17 | | - lane :install_dev_certificate do |
18 | | - # Improve DX. We cannot use an empty password, so we use the public password. |
19 | | - ENV["MATCH_PASSWORD"] = "AppleDeveloper1!" |
20 | | - match( |
21 | | - type: "development", |
22 | | - git_branch: "appdev", |
23 | | - profile_name: "Make It Native 9 Dev (Match)", |
24 | | - readonly: true, |
25 | | - ) |
26 | | - end |
27 | | - |
28 | | - desc "Build an internal version for automation" |
29 | | - desc "It always uses v.0.0.0 and build number 0 by design" |
30 | | - lane :internal do |
31 | | - sh("npm", "ci", "--legacy-peer-deps") |
32 | | - cocoapods |
33 | | - increment_version_number( |
34 | | - version_number: "0.0.0", |
35 | | - ) |
36 | | - gym(scheme: "DeveloperApp", configuration: "ReleaseDevToolsEnabled", export_method: "development", build_path: "./builds/internal/intermediate", output_directory: "./builds/internal/output") |
37 | | - end |
| 4 | +default_platform(:ios) |
38 | 5 |
|
39 | | - desc "Builds and install DeveloperApp into the simulator" |
40 | | - desc "This will use iPhone 13 Pro simulator with OS 15.5" |
41 | | - lane :debug_internal do |
42 | | - UI.message("Installing dependencies") |
43 | | - sh("npm", "i", "--legacy-peer-deps") |
44 | | - cocoapods |
45 | | - UI.message("Building and installing DeveloperApp") |
46 | | - gym( |
47 | | - scheme: "DeveloperApp", |
48 | | - configuration: "Debug", |
49 | | - skip_package_ipa: true, |
50 | | - skip_package_pkg: true, |
51 | | - sdk: "iphonesimulator", |
52 | | - destination: "platform=iOS Simulator,name=iPhone 13 Pro,OS=15.5", |
53 | | - xcargs: "ONLY_ACTIVE_ARCH=NO", |
| 6 | +platform :ios do |
| 7 | + desc "Upload a new build to AppStore" |
| 8 | + lane :release do |
| 9 | + keychain_name = "MiN_10_keychain" |
| 10 | + create_keychain( |
| 11 | + name: keychain_name, |
| 12 | + default_keychain: true, |
| 13 | + unlock: true, |
| 14 | + timeout: 3600, |
| 15 | + password: ENV["KEYCHAIN_PASSWORD"], |
| 16 | + lock_when_sleeps: false |
54 | 17 | ) |
55 | | - end |
56 | | - |
57 | | - desc "Submit a new Beta Build to Apple TestFlight" |
58 | | - desc "This will also make sure the profile is up to date" |
59 | | - lane :beta do |options| |
60 | | - keychain_name = "min_10_ios" |
61 | 18 | sh("npm", "ci", "--legacy-peer-deps") |
62 | 19 | cocoapods |
63 | 20 |
|
64 | | - UI.message("Connect API key") |
65 | | - app_store_connect_api_key( |
66 | | - is_key_content_base64: true, |
67 | | - ) |
68 | | - |
69 | | - create_keychain( |
70 | | - name: keychain_name, |
71 | | - unlock: true, |
72 | | - timeout: 0, |
73 | | - default_keychain: true, |
| 21 | + api_key = app_store_connect_api_key( |
| 22 | + key_id: ENV["APP_STORE_CONNECT_KEY_ID"], |
| 23 | + issuer_id: ENV["APP_STORE_CONNECT_ISSUER_ID"], |
| 24 | + key_content: ENV["APP_STORE_CONNECT_KEY_CONTENT"], |
| 25 | + duration: 1200, # Session Length in seconds (maximum: 1200). |
74 | 26 | ) |
75 | 27 |
|
76 | | - UI.message("Retrieve iOS certificate and profile") |
| 28 | + UI.message("Disabling automatic signing on Xcode") |
| 29 | + disable_automatic_code_signing |
| 30 | + |
| 31 | + UI.message("Get the certificates and profiles") |
77 | 32 | match( |
78 | | - type: "appstore", |
79 | | - keychain_name: keychain_name, |
| 33 | + type:"appstore", |
| 34 | + api_key:api_key, |
| 35 | + keychain_name:keychain_name, |
80 | 36 | keychain_password: ENV["KEYCHAIN_PASSWORD"], |
81 | | - profile_name: "match AppStore com.mendix.developerapp.native.mx10", |
82 | | - readonly: true, |
| 37 | + git_basic_authorization:ENV["MATCH_GIT_BASIC_AUTHORIZATION"], |
| 38 | + readonly: false, |
83 | 39 | ) |
84 | 40 |
|
85 | 41 | UI.message("Set version number") |
86 | 42 | increment_version_number( |
87 | 43 | version_number: APPLE_STORE_VERSION, |
88 | 44 | ) |
89 | 45 |
|
90 | | - UI.message("Set build number") |
91 | | - increment_build_number( |
92 | | - build_number: app_store_build_number(live: false, version: APPLE_STORE_VERSION, initial_build_number: 0) + 1, |
| 46 | + UI.message("Get the latest build number from AppStore Connect") |
| 47 | + build_num = app_store_build_number( |
| 48 | + live: false, |
| 49 | + initial_build_number: 0, |
| 50 | + api_key: api_key, |
| 51 | + version: APPLE_STORE_VERSION, |
93 | 52 | ) |
94 | 53 |
|
95 | | - unlock_keychain( # Unlock an existing keychain and add it to the keychain search list |
96 | | - path: keychain_name, |
97 | | - password: ENV["KEYCHAIN_PASSWORD"], |
98 | | - ) |
99 | | - |
100 | | - update_project_provisioning( |
| 54 | + UI.message("Set build number") |
| 55 | + increment_build_number( |
101 | 56 | xcodeproj: "developerapp.xcodeproj", |
102 | | - code_signing_identity: "Apple Distribution", |
103 | | - profile: ENV["sigh_com.mendix.developerapp.native.mx10_appstore_profile-path"], |
104 | | - build_configuration: "Release", |
105 | | - target_filter: "DeveloperApp", |
| 57 | + build_number: build_num + 1, |
106 | 58 | ) |
107 | 59 |
|
| 60 | + |
108 | 61 | UI.message("Replacing Google Maps API key from environment variables") |
109 | 62 | Dir.chdir("../DeveloperApp/Config") do |
110 | 63 | googleMapsApiKey = ENV["GOOGLE_MAPS_API_KEY"] || "GOOGLE_MAPS_API_KEY" |
111 | 64 | sh("sed -i '' 's/{{google-maps-api-key}}/#{googleMapsApiKey}/g' ApiKeys.xcconfig") |
112 | 65 | end |
113 | | - |
114 | | - UI.message("Build iOS app") |
115 | | - gym( |
| 66 | + |
| 67 | + build_app( |
| 68 | + workspace: "DeveloperApp.xcworkspace", |
116 | 69 | scheme: "DeveloperApp", |
117 | | - export_method: "app-store", |
118 | | - configuration: "Release", |
119 | | - output_directory: "./build/beta/output", |
120 | | - ) |
121 | | - |
122 | | - if options[:submit] == true |
123 | | - UI.message("Send iOS app to TestFlight") |
124 | | - pilot( |
125 | | - groups: ["Internal Testers"], |
126 | | - skip_submission: true, |
127 | | - skip_waiting_for_build_processing: true, |
128 | | - distribute_external: false |
129 | | - ) |
130 | | - end |
131 | | - |
132 | | - UI.message("Copy artifacts") |
133 | | - copy_artifacts( |
134 | | - target_path: "../artifacts", |
135 | | - artifacts: ["./build/beta/output/DeveloperApp.ipa", |
136 | | - "./build/beta/output/DeveloperApp.app.dSYM.zip"], |
137 | | - ) |
138 | | - end |
139 | | - |
140 | | - lane :beta_manually do |
141 | | - sh("npm", "ci", "--legacy-peer-deps") |
142 | | - cocoapods |
143 | | - |
144 | | - UI.message("Retrieve iOS certificate and profile") |
145 | | - match( |
146 | | - type: "appstore", |
147 | | - profile_name: "match AppStore com.mendix.developerapp.native.mx10", |
148 | | - readonly: true, |
149 | | - ) |
150 | | - |
151 | | - UI.message("Set version number") |
152 | | - increment_version_number( |
153 | | - version_number: APPLE_STORE_VERSION, |
| 70 | + build_path:"./build", |
| 71 | + output_directory:"./build" |
154 | 72 | ) |
155 | | - |
156 | | - UI.message("Set build number") |
157 | | - increment_build_number( |
158 | | - build_number: app_store_build_number(live: false, version: APPLE_STORE_VERSION, initial_build_number: 0) + 1, |
159 | | - ) |
160 | | - |
161 | | - UI.message("Build iOS app") |
162 | | - gym( |
163 | | - scheme: "DeveloperApp", |
164 | | - export_method: "app-store", |
165 | | - configuration: "Release", |
166 | | - output_directory: "./build/beta/output", |
167 | | - ) |
168 | | - |
169 | | - UI.message("Send iOS app to TestFlight") |
170 | | - pilot( |
171 | | - skip_submission: true, |
| 73 | + upload_to_testflight( |
172 | 74 | skip_waiting_for_build_processing: true, |
173 | 75 | ) |
174 | | - |
175 | | - UI.message("Copy artifacts") |
176 | | - copy_artifacts( |
177 | | - target_path: "../artifacts", |
178 | | - artifacts: ["./build/beta/output/DeveloperApp.ipa", |
179 | | - "./build/beta/output/DeveloperApp.app.dSYM.zip"], |
180 | | - ) |
181 | 76 | end |
182 | 77 |
|
183 | | - desc "Send appstore version to review" |
184 | | - lane :promote_to_production do |options| |
185 | | - if !options[:build_number] |
186 | | - UI.user_error!("build_number is required to release app") |
187 | | - end |
188 | | - |
189 | | - FileUtils.copy(ORIGINAL_CHANGELOG_PATH, FASTLANE_CHANGELOG_PATH) |
190 | | - |
191 | | - UI.message("Connect API key") |
192 | | - app_store_connect_api_key( |
193 | | - is_key_content_base64: true, |
194 | | - ) |
195 | | - |
196 | | - deliver( |
197 | | - app_version: APPLE_STORE_VERSION, |
198 | | - build_number: options[:build_number], |
199 | | - submit_for_review: true, |
200 | | - automatic_release: true, |
201 | | - force: true, |
202 | | - skip_metadata: false, |
203 | | - skip_screenshots: true, |
204 | | - skip_binary_upload: true, |
205 | | - precheck_include_in_app_purchases: false, |
206 | | - submission_information: { |
207 | | - add_id_info_uses_idfa: false, |
208 | | - export_compliance_uses_encryption: false, |
209 | | - }, |
210 | | - ) |
211 | | - end |
212 | 78 | end |
0 commit comments