Class: Deliver::Runner

Inherits:
Object
  • Object
show all
Defined in:
deliver/lib/deliver/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, skip_auto_detection = {}) ⇒ Runner

Returns a new instance of Runner.



19
20
21
22
23
24
25
26
# File 'deliver/lib/deliver/runner.rb', line 19

def initialize(options, skip_auto_detection = {})
  self.options = options

  

  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

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



17
18
19
# File 'deliver/lib/deliver/runner.rb', line 17

def options
  @options
end

Instance Method Details

#loginObject



28
29
30
31
32
33
# File 'deliver/lib/deliver/runner.rb', line 28

def 
  UI.message("Login to App Store Connect (#{options[:username]})")
  Spaceship::Tunes.(options[:username])
  Spaceship::Tunes.select_team
  UI.message("Login successful")
end

#precheck_appObject

Make sure we pass precheck before uploading



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'deliver/lib/deliver/runner.rb', line 53

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

#reject_version_if_possibleObject



161
162
163
164
165
166
167
168
169
# File 'deliver/lib/deliver/runner.rb', line 161

def reject_version_if_possible
  legacy_app = options[:app]
  app_id = legacy_app.apple_id
  app = Spaceship::ConnectAPI::App.get(app_id: app_id)

  if app.reject_version_if_possible!
    UI.success("Successfully rejected previous version!")
  end
end

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'deliver/lib/deliver/runner.rb', line 35

def run
  verify_version if options[:app_version].to_s.length > 0 && !options[:skip_app_version_update]
  

  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_reviewObject



171
172
173
# File 'deliver/lib/deliver/runner.rb', line 171

def submit_for_review
  SubmitForReview.new.submit!(options)
end

#upload_binaryObject

Upload the binary to App Store Connect



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'deliver/lib/deliver/runner.rb', line 127

def upload_binary
  UI.message("Uploading binary to App Store Connect")

  upload_ipa = options[:ipa]
  upload_pkg = options[:pkg]

  # 2020-01-27
  # Only verify platform if if both ipa and pkg exists (for backwards support)
  if upload_ipa && upload_pkg
    upload_ipa = ["ios", "appletvos"].include?(options[:platform])
    upload_pkg = options[:platform] == "osx"
  end

  if upload_ipa
    package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate(
      app_id: options[:app].apple_id,
      ipa_path: options[:ipa],
      package_path: "/tmp",
      platform: options[:platform]
    )
  elsif upload_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_metadataObject

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



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'deliver/lib/deliver/runner.rb', line 106

def 
   = UploadMetadata.new
  upload_screenshots = UploadScreenshots.new

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

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

  # Validate
  validate_html(screenshots)

  # Commit
  .upload(options)
  upload_screenshots.upload(options, screenshots)
  UploadPriceTier.new.upload(options)
end

#verify_versionObject

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



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'deliver/lib/deliver/runner.rb', line 87

def verify_version
  app_version = options[:app_version]
  UI.message("Making sure the latest version on App Store Connect matches '#{app_version}'...")

  legacy_app = options[:app]
  app_id = legacy_app.apple_id
  app = Spaceship::ConnectAPI::App.get(app_id: app_id)

  platform = Spaceship::ConnectAPI::Platform.map(options[:platform])
  changed = app.ensure_version!(app_version, platform: 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