@@ -75,4 +75,79 @@ platform :ios do
7575 )
7676 end
7777
78+ desc "Build new app and optionally upload to TestFlight"
79+ lane :internal do |options |
80+ keychain_name = "MiN_10_keychain"
81+ create_keychain (
82+ name : keychain_name ,
83+ default_keychain : true ,
84+ unlock : true ,
85+ timeout : 3600 ,
86+ password : ENV [ "KEYCHAIN_PASSWORD" ] ,
87+ lock_when_sleeps : false
88+ )
89+ sh ( "npm" , "ci" , "--legacy-peer-deps" )
90+ cocoapods
91+
92+ api_key = app_store_connect_api_key (
93+ key_id : ENV [ "APP_STORE_CONNECT_KEY_ID" ] ,
94+ issuer_id : ENV [ "APP_STORE_CONNECT_ISSUER_ID" ] ,
95+ key_content : ENV [ "APP_STORE_CONNECT_KEY_CONTENT" ] ,
96+ duration : 1200 , # Session Length in seconds (maximum: 1200).
97+ )
98+
99+ UI . message ( "Disabling automatic signing on Xcode" )
100+ disable_automatic_code_signing
101+
102+ UI . message ( "Get the certificates and profiles" )
103+ match (
104+ type :"appstore" ,
105+ api_key :api_key ,
106+ keychain_name :keychain_name ,
107+ keychain_password : ENV [ "KEYCHAIN_PASSWORD" ] ,
108+ git_basic_authorization :ENV [ "MATCH_GIT_BASIC_AUTHORIZATION" ] ,
109+ readonly : false ,
110+ )
111+
112+ UI . message ( "Set version number" )
113+ increment_version_number (
114+ version_number : APPLE_STORE_VERSION ,
115+ )
116+
117+ UI . message ( "Get the latest build number from AppStore Connect" )
118+ build_num = app_store_build_number (
119+ live : false ,
120+ initial_build_number : 0 ,
121+ api_key : api_key ,
122+ version : APPLE_STORE_VERSION ,
123+ )
124+
125+ UI . message ( "Set build number" )
126+ increment_build_number (
127+ xcodeproj : "developerapp.xcodeproj" ,
128+ build_number : build_num + 1 ,
129+ )
130+
131+ UI . message ( "Replacing Google Maps API key from environment variables" )
132+ Dir . chdir ( "../DeveloperApp/Config" ) do
133+ googleMapsApiKey = ENV [ "GOOGLE_MAPS_API_KEY" ] || "GOOGLE_MAPS_API_KEY"
134+ sh ( "sed -i '' 's/{{google-maps-api-key}}/#{ googleMapsApiKey } /g' ApiKeys.xcconfig" )
135+ end
136+
137+ build_app (
138+ workspace : "DeveloperApp.xcworkspace" ,
139+ scheme : "DeveloperApp" ,
140+ build_path :"./build" ,
141+ output_directory :"./build"
142+ )
143+
144+ if options [ :submit ] == true
145+ UI . message "Uploading build to TestFlight"
146+ upload_to_testflight (
147+ skip_waiting_for_build_processing : true ,
148+ )
149+ else
150+ UI . message "Build completed successfully. Skipping upload to TestFlight."
151+ end
152+ end
78153end
0 commit comments