pilot/lib/pilot/build_manager.rb in fastlane-2.120.0.beta.20190409200021 vs pilot/lib/pilot/build_manager.rb in fastlane-2.120.0

- old
+ new

@@ -56,14 +56,14 @@ def wait_for_build_processing_to_be_complete platform = fetch_app_platform app_version = FastlaneCore::IpaFileAnalyser.fetch_app_version(config[:ipa]) app_build = FastlaneCore::IpaFileAnalyser.fetch_app_build(config[:ipa]) - latest_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: app.apple_id, platform: platform, train_version: app_version, build_version: app_build, poll_interval: config[:wait_processing_interval], strict_build_watch: config[:wait_for_uploaded_build]) + latest_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: app.apple_id, platform: platform, train_version: app_version, build_version: app_build, poll_interval: config[:wait_processing_interval]) unless latest_build.train_version == app_version && latest_build.build_version == app_build - UI.important("Uploaded app #{app_version} - #{app_build}, but received build #{latest_build.train_version} - #{latest_build.build_version}. If you want to wait for uploaded build to be finished processing, use the `wait_for_uploaded_build` option") + UI.important("Uploaded app #{app_version} - #{app_build}, but received build #{latest_build.train_version} - #{latest_build.build_version}.") end return latest_build end @@ -119,10 +119,13 @@ rows: FastlaneCore::PrintTable.transform_output(rows) )) end def update_beta_app_meta(options, build) + # App Store Connect API build id + build_id = build.find_app_store_connect_build["id"] + # Setting account required wth AppStore Connect API update_review_detail(build.app_id, { demo_account_required: options[:demo_account_required] }) if should_update_beta_app_review_info(options) update_review_detail(build.app_id, options[:beta_app_review_info]) @@ -141,21 +144,21 @@ UI.user_error!("Could not set beta_app_feedback_email and/or beta_app_description: #{ex}") end end if should_update_localized_build_information?(options) - update_localized_build_review(build, options[:localized_build_info]) + update_localized_build_review(build_id, options[:localized_build_info]) elsif should_update_build_information?(options) begin - update_localized_build_review(build, {}, default_info: { whats_new: options[:changelog] }) + update_localized_build_review(build_id, {}, default_info: { whats_new: options[:changelog] }) UI.success("Successfully set the changelog for build") rescue => ex UI.user_error!("Could not set changelog: #{ex}") end end - update_build_beta_details(build, { + update_build_beta_details(build_id, { auto_notify_enabled: options[:notify_external_testers] }) end def self.truncate_changelog(changelog) @@ -249,27 +252,31 @@ raise ex unless updated_build.approved? end end if options[:groups] - groups = Spaceship::TestFlight::Group.filter_groups(app_id: uploaded_build.app_id) do |group| - options[:groups].include?(group.name) + client = Spaceship::ConnectAPI::Base.client + beta_group_ids = client.get_beta_groups(filter: { app: uploaded_build.app_id }).select do |group| + options[:groups].include?(group["attributes"]["name"]) + end.map do |group| + group["id"] end - groups.each do |group| - uploaded_build.add_group!(group) - end - end - if options[:distribute_external] - external_group = Spaceship::TestFlight::Group.default_external_group(app_id: uploaded_build.app_id) - uploaded_build.add_group!(external_group) unless external_group.nil? + unless beta_group_ids.empty? + build = uploaded_build.find_app_store_connect_build + build_id = build["id"] - if external_group.nil? && options[:groups].nil? - UI.user_error!("You must specify at least one group using the `:groups` option to distribute externally") + client.add_beta_groups_to_build(build_id: build_id, beta_group_ids: beta_group_ids) end end + if options[:distribute_external] && options[:groups].nil? + # Legacy Spaceship::TestFlight API used to have a `default_external_group` that would automatically + # get selected but this no longer exists with Spaceship::ConnectAPI + UI.user_error!("You must specify at least one group using the `:groups` option to distribute externally") + end + true end def set_export_compliance_if_needed(uploaded_build, options) build = uploaded_build.find_app_store_connect_build @@ -351,14 +358,11 @@ attributes[:locale] = locale if locale client.post_beta_app_localizations(app_id: app_id, attributes: attributes) end end - def update_localized_build_review(build, info_by_lang, default_info: nil) - resp = Spaceship::ConnectAPI::Base.client.get_builds(filter: { expired: false, processingState: "PROCESSING,VALID", version: build.build_version }) - build_id = resp.first["id"] - + def update_localized_build_review(build_id, info_by_lang, default_info: nil) info_by_lang = info_by_lang.collect { |k, v| [k.to_sym, v] }.to_h if default_info info_by_lang.delete(:default) else @@ -399,15 +403,11 @@ attributes[:locale] = locale if locale client.post_beta_build_localizations(build_id: build_id, attributes: attributes) end end - def update_build_beta_details(build, info) + def update_build_beta_details(build_id, info) client = Spaceship::ConnectAPI::Base.client - - build = build.find_app_store_connect_build - build_id = build["id"] - resp = client.get_build_beta_details(filter: { build: build_id }) build_beta_details_id = resp.first["id"] attributes = {} attributes[:autoNotifyEnabled] = info[:auto_notify_enabled] if info.key?(:auto_notify_enabled)