deliver/lib/deliver/runner.rb in fastlane_hotfix-2.165.1 vs deliver/lib/deliver/runner.rb in fastlane_hotfix-2.187.0

- old
+ new

@@ -24,28 +24,28 @@ Deliver::DetectValues.new.run!(self.options, skip_auto_detection) FastlaneCore::PrintTable.print_values(config: options, hide_keys: [:app], mask_keys: ['app_review_information.demo_password'], title: "deliver #{Fastlane::VERSION} Summary") end def login - if api_token + if (api_token = Spaceship::ConnectAPI::Token.from(hash: options[:api_key], filepath: options[:api_key_path])) UI.message("Creating authorization token for App Store Connect API") Spaceship::ConnectAPI.token = api_token + elsif !Spaceship::ConnectAPI.token.nil? + UI.message("Using existing authorization token for App Store Connect API") else + # Username is now optional since addition of App Store Connect API Key + # Force asking for username to prompt user if not already set + options.fetch(:username, force_ask: true) + # Team selection passed though FASTLANE_TEAM_ID and FASTLANE_TEAM_NAME environment variables # Prompts select team if multiple teams and none specified UI.message("Login to App Store Connect (#{options[:username]})") Spaceship::ConnectAPI.login(options[:username], nil, use_portal: false, use_tunes: true) UI.message("Login successful") end end - def api_token - @api_token ||= Spaceship::ConnectAPI::Token.create(options[:api_key]) if options[:api_key] - @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(options[:api_key_path]) if options[:api_key_path] - return @api_token - end - def run verify_version if options[:app_version].to_s.length > 0 && !options[:skip_app_version_update] # Rejecting before upload meta # Screenshots can not be update/deleted if in waiting for review @@ -81,11 +81,11 @@ app_identifier: options[:app_identifier] } if options[:api_key] || options[:api_key_path] if options[:precheck_include_in_app_purchases] - UI.user_error!("Precheck cannot check In-app purchases with the App Store Connect API Key (yet). Exclude In-app purchases from precheck or use Apple ID login") + UI.user_error!("Precheck cannot check In-app purchases with the App Store Connect API Key (yet). Exclude In-app purchases from precheck, disable the precheck step in your build step, or use Apple ID login") end precheck_options[:api_key] = options[:api_key] precheck_options[:api_key_path] = options[:api_key_path] else @@ -112,11 +112,11 @@ # If not, the new version will automatically be created def verify_version app_version = options[:app_version] UI.message("Making sure the latest version on App Store Connect matches '#{app_version}'...") - app = options[:app] + app = Deliver.cache[:app] platform = Spaceship::ConnectAPI::Platform.map(options[:platform]) changed = app.ensure_version!(app_version, platform: platform) if changed @@ -161,31 +161,35 @@ upload_pkg = options[:platform] == "osx" end if upload_ipa package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate( - app_id: options[:app].id, + app_id: Deliver.cache[:app].id, ipa_path: options[:ipa], package_path: "/tmp", platform: options[:platform] ) elsif upload_pkg package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate( - app_id: options[:app].id, + app_id: Deliver.cache[:app].id, pkg_path: options[:pkg], package_path: "/tmp", platform: options[:platform] ) end transporter = transporter_for_selected_team - result = transporter.upload(options[:app].id, package_path) - UI.user_error!("Could not upload binary to App Store Connect. Check out the error above", show_github_issues: true) unless result + result = transporter.upload(package_path: package_path) + + unless result + transporter_errors = transporter.displayable_errors + UI.user_error!("Error uploading ipa file: \n #{transporter_errors}") + end end def reject_version_if_possible - app = options[:app] + app = Deliver.cache[:app] platform = Spaceship::ConnectAPI::Platform.map(options[:platform]) if app.reject_version_if_possible!(platform: platform) UI.success("Successfully rejected previous version!") end end @@ -200,9 +204,10 @@ # If itc_provider was explicitly specified, use it. # If there are multiple teams, infer the provider from the selected team name. # If there are fewer than two teams, don't infer the provider. def transporter_for_selected_team # Use JWT auth + api_token = Spaceship::ConnectAPI.token unless api_token.nil? api_token.refresh! if api_token.expired? return FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, api_token.text) end