pilot/lib/pilot/build_manager.rb in fastlane-2.28.0.beta.20170420010017 vs pilot/lib/pilot/build_manager.rb in fastlane-2.28.0
- old
+ new
@@ -33,44 +33,21 @@
UI.important("This means that no changelog will be set and no build will be distributed to testers")
return
end
UI.message("If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option")
- uploaded_build = wait_for_processing_build(options, platform) # this might take a while
+ latest_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: app.apple_id, platform: platform)
- distribute(options, uploaded_build)
+ distribute(options, latest_build)
end
- def distribute(options, build = nil)
+ def distribute(options, build)
start(options)
if config[:apple_id].to_s.length == 0 and config[:app_identifier].to_s.length == 0
config[:app_identifier] = UI.input("App Identifier: ")
end
- if build.nil?
- platform = fetch_app_platform(required: false)
- builds = app.all_processing_builds(platform: platform) + app.builds(platform: platform)
- # sort by upload_date
- builds.sort! { |a, b| a.upload_date <=> b.upload_date }
- build = builds.last
- if build.nil?
- UI.user_error!("No builds found.")
- return
- end
- if build.processing
- UI.user_error!("Build #{build.train_version}(#{build.build_version}) is still processing.")
- return
- end
- if build.testing_status == "External"
- UI.user_error!("Build #{build.train_version}(#{build.build_version}) has already been distributed.")
- return
- end
-
- type = options[:distribute_external] ? 'External' : 'Internal'
- UI.message("Distributing build #{build.train_version}(#{build.build_version}) from #{build.testing_status} -> #{type}")
- end
-
unless config[:update_build_info_on_upload]
if should_update_build_information(options)
build.update_build_information!(whats_new: options[:changelog], description: options[:beta_app_description], feedback_email: options[:beta_app_feedback_email])
UI.success "Successfully set the changelog and/or description for build"
end
@@ -126,90 +103,36 @@
def should_update_build_information(options)
options[:changelog].to_s.length > 0 or options[:beta_app_description].to_s.length > 0 or options[:beta_app_feedback_email].to_s.length > 0
end
- # This method will takes care of checking for the processing builds every few seconds
- # @return [Build] The build that we just uploaded
- def wait_for_processing_build(options, platform)
- # the upload date of the new buid
- # we use it to identify the build
- start = Time.now
- wait_processing_interval = config[:wait_processing_interval].to_i
- latest_build = nil
- UI.message("Waiting for iTunes Connect to process the new build")
- must_update_build_info = config[:update_build_info_on_upload]
- loop do
- sleep(wait_processing_interval)
+ def distribute_build(uploaded_build, options)
+ UI.message("Distributing new build to testers: #{uploaded_build.train_version} - #{uploaded_build.build_version}")
- # before we look for processing builds, we need to ensure that there
- # is a build train for this application; new applications don't
- # build trains right away, and if we don't do this check, we will
- # get break out of this loop and then generate an error later when we
- # have a nil build
- if app.build_trains(platform: platform).count == 0
- UI.message("New application; waiting for build train to appear on iTunes Connect")
- else
- builds = app.all_processing_builds(platform: platform)
- latest_build = builds.last unless latest_build
- break unless builds.include?(latest_build)
+ # This is where we could add a check to see if encryption is required and has been updated
+ uploaded_build.export_compliance.encryption_updated = false
+ uploaded_build.beta_review_info.demo_account_required = false
+ uploaded_build.submit_for_testflight_review!
- if latest_build.valid and must_update_build_info
- # Set the changelog and/or description if necessary
- if should_update_build_information(options)
- latest_build.update_build_information!(whats_new: options[:changelog], description: options[:beta_app_description], feedback_email: options[:beta_app_feedback_email])
- UI.success "Successfully set the changelog and/or description for build"
- end
- must_update_build_info = false
- 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?
- UI.message("Waiting for iTunes Connect to finish processing the new build (#{latest_build.train_version} - #{latest_build.build_version})")
+ if external_group.nil? && options[:groups].nil?
+ UI.user_error!("You must specify at least one group using the `:groups` option to distribute externally")
end
+
end
- UI.user_error!("Error receiving the newly uploaded binary, please check iTunes Connect") if latest_build.nil?
- full_build = nil
-
- while full_build.nil? || full_build.processing
- # The build's processing state should go from true to false, and be done. But sometimes it goes true -> false ->
- # true -> false, where the second true is transient. This causes a spurious failure. Find build by build_version
- # and ensure it's not processing before proceeding - it had to have already been false before, to get out of the
- # previous loop.
- full_build = app.build_trains(platform: platform)[latest_build.train_version].builds.find do |b|
- b.build_version == latest_build.build_version
+ if options[:groups]
+ groups = Group.filter_groups(app_id: uploaded_build.app_id) do |group|
+ options[:groups].include?(group.name)
end
-
- UI.message("Waiting for iTunes Connect to finish processing the new build (#{latest_build.train_version} - #{latest_build.build_version})")
- sleep(wait_processing_interval)
+ groups.each do |group|
+ uploaded_build.add_group!(group)
+ end
end
- if full_build && !full_build.processing && full_build.valid
- minutes = ((Time.now - start) / 60).round
- UI.success("Successfully finished processing the build")
- UI.message("You can now tweet: ")
- UI.important("iTunes Connect #iosprocessingtime #{minutes} minutes")
- return full_build
- else
- UI.user_error!("Error: Seems like iTunes Connect didn't properly pre-process the binary")
- end
- end
-
- def distribute_build(uploaded_build, options)
- UI.message("Distributing new build to testers")
-
- # Submit for review before external testflight is available
- if options[:distribute_external]
- uploaded_build.client.submit_testflight_build_for_review!(
- app_id: uploaded_build.build_train.application.apple_id,
- train: uploaded_build.build_train.version_string,
- build_number: uploaded_build.build_version,
- platform: uploaded_build.platform
- )
- end
-
- # Submit for beta testing
- type = options[:distribute_external] ? 'external' : 'internal'
- uploaded_build.build_train.update_testing_status!(true, type, uploaded_build)
- return true
+ true
end
end
end