class Deliver::Runner

Attributes

options[RW]

Public Class Methods

new(options, skip_auto_detection = {}) click to toggle source
# File deliver/lib/deliver/runner.rb, line 20
def initialize(options, skip_auto_detection = {})
  self.options = options

  login

  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

Public Instance Methods

login() click to toggle source
# File deliver/lib/deliver/runner.rb, line 29
def login
  UI.message("Login to App Store Connect (#{options[:username]})")
  Spaceship::Tunes.login(options[:username])
  Spaceship::Tunes.select_team
  UI.message("Login successful")
end
precheck_app() click to toggle source

Make sure we pass precheck before uploading

# File deliver/lib/deliver/runner.rb, line 54
def precheck_app
  return true unless options[:run_precheck_before_submit]
  UI.message("Running precheck before submitting to review, if you'd like to disable this check you can set run_precheck_before_submit to false")

  if options[:submit_for_review]
    UI.message("Making sure we pass precheck 👮‍♀️ 👮 before we submit  🛫")
  else
    UI.message("Running precheck 👮‍♀️ 👮")
  end

  precheck_options = {
    default_rule_level: options[:precheck_default_rule_level],
    include_in_app_purchases: options[:precheck_include_in_app_purchases],
    app_identifier: options[:app_identifier],
    username: options[:username]
  }

  precheck_config = FastlaneCore::Configuration.create(Precheck::Options.available_options, precheck_options)
  Precheck.config = precheck_config

  precheck_success = true
  begin
    precheck_success = Precheck::Runner.new.run
  rescue => ex
    UI.error("fastlane precheck just tried to inspect your app's metadata for App Store guideline violations and ran into a problem. We're not sure what the problem was, but precheck failed to finished. You can run it in verbose mode if you want to see the whole error. We'll have a fix out soon 🚀")
    UI.verbose(ex.inspect)
    UI.verbose(ex.backtrace.join("\n"))
  end

  return precheck_success
end
prepare_app_icons(options = {}) click to toggle source

If options/options is supplied value/path will be used. If it is unset files (app_icon/watch_icon) exists in the fastlane/metadata/ folder, those will be used

# File deliver/lib/deliver/runner.rb, line 130
def prepare_app_icons(options = {})
  return unless options[:metadata_path]

  default_app_icon_path = Dir[File.join(options[:metadata_path], "app_icon.{png,jpg}")].first
  options[:app_icon] ||= default_app_icon_path if default_app_icon_path && File.exist?(default_app_icon_path)

  default_watch_icon_path = Dir[File.join(options[:metadata_path], "watch_icon.{png,jpg}")].first
  options[:apple_watch_app_icon] ||= default_watch_icon_path if default_watch_icon_path && File.exist?(default_watch_icon_path)
end
reject_version_if_possible() click to toggle source
# File deliver/lib/deliver/runner.rb, line 164
def reject_version_if_possible
  app = options[:app]
  if app.reject_version_if_possible!
    UI.success("Successfully rejected previous version!")
  end
end
run() click to toggle source
# File deliver/lib/deliver/runner.rb, line 36
def run
  verify_version if options[:app_version].to_s.length > 0 && !options[:skip_app_version_update]
  upload_metadata

  has_binary = (options[:ipa] || options[:pkg])
  if !options[:skip_binary_upload] && !options[:build_number] && has_binary
    upload_binary
  end

  UI.success("Finished the upload to App Store Connect") unless options[:skip_binary_upload]

  reject_version_if_possible if options[:reject_if_possible]

  precheck_success = precheck_app
  submit_for_review if options[:submit_for_review] && precheck_success
end
submit_for_review() click to toggle source
# File deliver/lib/deliver/runner.rb, line 171
def submit_for_review
  SubmitForReview.new.submit!(options)
end
upload_binary() click to toggle source

Upload the binary to App Store Connect

# File deliver/lib/deliver/runner.rb, line 141
def upload_binary
  UI.message("Uploading binary to App Store Connect")
  if options[:ipa]
    package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate(
      app_id: options[:app].apple_id,
      ipa_path: options[:ipa],
      package_path: "/tmp",
      platform: options[:platform]
    )
  elsif options[:pkg]
    package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate(
      app_id: options[:app].apple_id,
      pkg_path: options[:pkg],
      package_path: "/tmp",
      platform: options[:platform]
    )
  end

  transporter = transporter_for_selected_team
  result = transporter.upload(options[:app].apple_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
end
upload_metadata() click to toggle source

Upload all metadata, screenshots, pricing information, etc. to App Store Connect

# File deliver/lib/deliver/runner.rb, line 102
def upload_metadata
  upload_metadata = UploadMetadata.new
  upload_screenshots = UploadScreenshots.new

  # First, collect all the things for the HTML Report
  screenshots = upload_screenshots.collect_screenshots(options)
  upload_metadata.load_from_filesystem(options)

  # Assign "default" values to all languages
  upload_metadata.assign_defaults(options)

  # Handle app icon / watch icon
  prepare_app_icons(options)

  # Validate
  validate_html(screenshots)

  # Commit
  upload_metadata.upload(options)
  upload_screenshots.upload(options, screenshots)
  UploadPriceTier.new.upload(options)
  UploadAssets.new.upload(options) # e.g. app icon
end
verify_version() click to toggle source

Make sure the version on App Store Connect matches the one in the ipa If not, the new version will automatically be created

# File deliver/lib/deliver/runner.rb, line 88
def verify_version
  app_version = options[:app_version]
  UI.message("Making sure the latest version on App Store Connect matches '#{app_version}' from the ipa file...")

  changed = options[:app].ensure_version!(app_version, platform: options[:platform])

  if changed
    UI.success("Successfully set the version to '#{app_version}'")
  else
    UI.success("'#{app_version}' is the latest version on App Store Connect")
  end
end

Private Instance Methods

transporter_for_selected_team() click to toggle source

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.

# File deliver/lib/deliver/runner.rb, line 180
def transporter_for_selected_team
  generic_transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider])
  return generic_transporter unless options[:itc_provider].nil? && Spaceship::Tunes.client.teams.count > 1

  begin
    team = Spaceship::Tunes.client.teams.find { |t| t['contentProvider']['contentProviderId'].to_s == Spaceship::Tunes.client.team_id }
    name = team['contentProvider']['name']
    provider_id = generic_transporter.provider_ids[name]
    UI.verbose("Inferred provider id #{provider_id} for team #{name}.")
    return FastlaneCore::ItunesTransporter.new(options[:username], nil, false, provider_id)
  rescue => ex
    UI.verbose("Couldn't infer a provider short name for team with id #{Spaceship::Tunes.client.team_id} automatically: #{ex}. Proceeding without provider short name.")
    return generic_transporter
  end
end
validate_html(screenshots) click to toggle source
# File deliver/lib/deliver/runner.rb, line 196
def validate_html(screenshots)
  return if options[:force]
  return if options[:skip_metadata] && options[:skip_screenshots]
  HtmlGenerator.new.run(options, screenshots)
end