@@ -17,21 +17,29 @@ default_platform(:android)
1717
1818desc "Make sure to copy the `.env.dist` to `.env` and fill all values before running any lanes"
1919
20+ exit_messages = [ ]
21+
2022platform :ios do
21- before_all do
22- ENV [ "NO_FLIPPER" ] = "1" # Disable Flipper in Release builds
23- end
24-
23+
2524 desc 'Fetch certificates and provisioning profiles'
2625 lane :certificates do
27- match ( type : 'development' , keychain_password : ENV [ 'MATCH_PASSWORD' ] )
28- match ( type : 'appstore' , keychain_password : ENV [ 'MATCH_PASSWORD' ] )
26+ setup_ci if ENV [ 'CI' ]
27+ match ( type : 'development' )
28+ match ( type : 'appstore' )
29+ rescue => exception
30+ exit_messages << [
31+ "HELP: If certificates are EXPIRED/NOT VALID run" ,
32+ "" ,
33+ " fastlane ios certificates_reset" ,
34+ "" ,
35+ "and follow the instructions presented there." ,
36+ ]
37+ raise exception
2938 end
3039
3140 desc 'Build the iOS application.'
3241 lane :build do
33- # certificates
34-
42+ certificates if ENV [ 'CI' ]
3543 require "json"
3644 package_json = JSON . parse ( File . read ( "../package.json" ) )
3745 increment_version_number_in_xcodeproj (
@@ -42,13 +50,17 @@ platform :ios do
4250 xcodeproj : "ios/TodoistHabitSync.xcodeproj"
4351 )
4452
53+ # xcversion(version: "16.3")
4554 gym
46-
47- echo ( message : "----------------------------------------------------------" )
48- echo ( message : "HELP: If the build FAILED, make sure to..." )
49- echo ( message : " (1) run `fastlane ios certificates`, AND" )
50- echo ( message : " (2) unlock the keychain with `security unlock-keychain`." )
51- echo ( message : "----------------------------------------------------------" )
55+ rescue => exception
56+ exit_messages << [
57+ "HELP: If the build FAILED, make sure to..." ,
58+ " - [ ] `npm run pods` - Install native dependencies" ,
59+ " - [ ] `fastlane ios certificates` - Install certificates/provisioning profiles" ,
60+ " - [ ] `security unlock-keychain` - Allow pulling private signing keys from the keychain (e.g. in SSH sessions)" ,
61+ " - [ ] Try running this command directly on the Mac (not over SSH) to handle GUI prompts"
62+ ]
63+ raise exception
5264 end
5365
5466 desc "Publish a beta release to the App Store"
@@ -59,7 +71,56 @@ platform :ios do
5971 issuer_id : ENV [ "IOS_APP_STORE_CONNECT_ISSUER_ID" ] ,
6072 key_filepath : ENV [ "IOS_APP_STORE_CONNECT_KEY_FILE_PATH" ] ,
6173 )
62- pilot
74+ upload_to_testflight
75+ end
76+
77+ desc "Publish a production release to the App Store"
78+ lane :production do
79+ build
80+ app_store_connect_api_key (
81+ key_id : ENV [ "IOS_APP_STORE_CONNECT_KEY_ID" ] ,
82+ issuer_id : ENV [ "IOS_APP_STORE_CONNECT_ISSUER_ID" ] ,
83+ key_filepath : ENV [ "IOS_APP_STORE_CONNECT_KEY_FILE_PATH" ] ,
84+ )
85+ upload_to_app_store (
86+ precheck_include_in_app_purchases : false ,
87+ submission_information : {
88+ add_id_info_uses_idfa : false ,
89+ } ,
90+ submit_for_review : true ,
91+ metadata_path : "./fastlane/metadata/ios" ,
92+ force : true
93+ )
94+ end
95+
96+ desc 'Reset certificates and provisioning profiles (e.g. after expiration)'
97+ lane :certificates_reset do
98+ print_message_block [
99+ "👀 Resetting certificates takes some manual work..." ,
100+ " (1) App Store Connect" ,
101+ " - [ ] Revoke expired certificates: https://developer.apple.com/account/resources/certificates/list" ,
102+ " - [ ] Revoke expired profiles: https://developer.apple.com/account/resources/profiles/list" ,
103+ " (2) Git: #{ ENV [ 'IOS_CERTIFICATE_REPOSITORY_URL' ] } " ,
104+ " - [ ] Delete expired certificates (.cer, .p12)" ,
105+ " - [ ] Delete expired profiles (.mobileprovision)" ,
106+ ]
107+ complete = prompt ( text : "Have you completed the manual steps above?" , boolean : true )
108+ if complete
109+ echo ( message : "🏗️ Attempting to update certificates" )
110+ begin
111+ sh ( 'sed -i "" "s/readonly/# readonly/" Matchfile' ) # Make certificates editable
112+ certificates
113+ print_message_block [
114+ "✅ Certificates updated." ,
115+ "👀 Double check your keychain to ensure old certs are no longer installed." ,
116+ "🆘 If you still have signing problems, try here: https://forums.developer.apple.com/forums/thread/712005" ,
117+ ]
118+ ensure
119+ sh ( 'sed -i "" "s/# readonly/readonly/" Matchfile' ) # Re-lock edits of certificates
120+ end
121+ else
122+ echo ( message : "❌ Certificates were NOT adjusted" )
123+ end
63124 end
64125
65126end
@@ -68,16 +129,16 @@ platform :android do
68129
69130 desc "Build the Android application."
70131 lane :build do
71- gradle ( task : 'clean' , project_dir : 'android/' )
72132 gradle ( task : 'incrementVersionCode' , project_dir : 'android/' )
73- gradle ( task : 'syncVersionNameFromPackageJson' , project_dir : 'android/' )
133+ gradle ( task : 'syncVersionName' , project_dir : 'android/' )
134+ gradle ( task : 'clean' , project_dir : 'android/' )
74135 gradle ( task : 'bundle' , build_type : 'Release' , project_dir : 'android/' )
75136 end
76137
77138 desc "Publish an internal release to the Play Store"
78139 lane :internal do
79140 build
80- supply ( track : 'internal' , track_promote_to : 'internal' , release_status : 'draft' )
141+ supply ( track : 'internal' , track_promote_to : 'internal' )
81142 end
82143
83144 desc "Publish a alpha release to the Play Store"
@@ -98,4 +159,20 @@ platform :android do
98159 supply ( track : 'production' , track_promote_to : 'production' )
99160 end
100161
162+ end
163+
164+ def print_message_block ( message )
165+ echo ( message : "----------------------------------------------------------" )
166+ if message . is_a? ( Array )
167+ message . each { |line | echo ( message : line ) }
168+ else
169+ echo ( message : message )
170+ end
171+ echo ( message : "----------------------------------------------------------" )
172+ end
173+
174+ at_exit do |status |
175+ exit_messages . each do |message |
176+ print_message_block message
177+ end
101178end
0 commit comments