Class: Deliver::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
10
# File 'lib/deliver/runner.rb', line 5

def initialize(options)
  self.options = options
  
  Deliver::DetectValues.new.run!(self.options)
  FastlaneCore::PrintTable.print_values(config: options, hide_keys: [:app], title: "deliver #{Deliver::VERSION} Summary")
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/deliver/runner.rb', line 3

def options
  @options
end

Instance Method Details

#loginObject



12
13
14
15
16
17
# File 'lib/deliver/runner.rb', line 12

def 
  Helper.log.info "Login to iTunes Connect (#{options[:username]})"
  Spaceship::Tunes.(options[:username])
  Spaceship::Tunes.select_team
  Helper.log.info "Login successful"
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/deliver/runner.rb', line 19

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

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

  Helper.log.info "Finished the upload to iTunes Connect".green

  submit_for_review if options[:submit_for_review]
end

#submit_for_reviewObject



84
85
86
# File 'lib/deliver/runner.rb', line 84

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

#upload_binaryObject

Upload the binary to iTunes Connect



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/deliver/runner.rb', line 64

def upload_binary
  Helper.log.info "Uploading binary to iTunes Connect"
  if options[:ipa]
    package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate(
      app_id: options[:app].apple_id,
      ipa_path: options[:ipa],
      package_path: "/tmp"
    )
  elsif options[:pkg]
    package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate(
      app_id: options[:app].apple_id,
      pkg_path: options[:pkg],
      package_path: "/tmp"
    )
  end

  transporter = FastlaneCore::ItunesTransporter.new(options[:username])
  transporter.upload(options[:app].apple_id, package_path)
end

#upload_metadataObject

Upload all metadata, screenshots, pricing information, etc. to iTunes Connect



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/deliver/runner.rb', line 48

def 
  # First, collect all the things for the HTML Report
  screenshots = UploadScreenshots.new.collect_screenshots(options)
  UploadMetadata.new.load_from_filesystem(options)

  # Validate
  validate_html(screenshots)

  # Commit
  UploadMetadata.new.upload(options)
  UploadScreenshots.new.upload(options, screenshots)
  UploadPriceTier.new.upload(options)
  UploadAssets.new.upload(options) # e.g. app icon
end

#verify_versionObject

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



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

def verify_version
  app_version = options[:app_version]
  Helper.log.info "Making sure the latest version on iTunes Connect matches '#{app_version}' from the ipa file..."

  changed = options[:app].ensure_version!(app_version)
  if changed
    Helper.log.info "Successfully set the version to '#{app_version}'".green
  else
    Helper.log.info "'#{app_version}' is the latest version on iTunes Connect".green
  end
end