Class: Deliver::SubmitForReview

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

Instance Method Summary collapse

Instance Method Details

#find_build(candidate_builds) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'deliver/lib/deliver/submit_for_review.rb', line 107

def find_build(candidate_builds)
  if (candidate_builds || []).count == 0
    UI.user_error!("Could not find any available candidate builds on App Store Connect to submit")
  end

  build = candidate_builds.first
  candidate_builds.each do |b|
    if b.upload_date > build.upload_date
      build = b
    end
  end

  return build
end

#submit!(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'deliver/lib/deliver/submit_for_review.rb', line 5

def submit!(options)
  app = options[:app]
  select_build(options)

  UI.message("Submitting the app for review...")
  submission = app.create_submission(platform: options[:platform])

  # Set app submission information
  # Default Values
  submission.content_rights_contains_third_party_content = false
  submission.content_rights_has_rights = true
  submission.add_id_info_uses_idfa = false

  # User Values
  if options[:submission_information]
    options[:submission_information].each do |key, value|
      UI.message("Setting '#{key}' to '#{value}'...")
      submission.send("#{key}=", value)
    end
  end

  # Finalize app submission
  submission.complete!

  UI.success("Successfully submitted the app for review!")
end

#wait_for_build(app, app_version) ⇒ Object



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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'deliver/lib/deliver/submit_for_review.rb', line 55

def wait_for_build(app, app_version)
  UI.user_error!("Could not find app with app identifier") unless app

  start = Time.now
  build = nil

  loop do
    # Sometimes candidate_builds don't appear immediately after submission
    # Wait for candidate_builds to appear on App Store Connect
    # Issue https://github.com/fastlane/fastlane/issues/10411
    candidate_builds = app.latest_version.candidate_builds
    if (candidate_builds || []).count == 0
      UI.message("Waiting for candidate builds to appear...")
      if (Time.now - start) > (60 * 5)
        UI.user_error!("Could not find any available candidate builds on App Store Connect to submit")
      else
        sleep(30)
        next
      end
    end

    latest_build = find_build(candidate_builds)

    # if the app version isn't present in the hash (could happen if we are waiting for submission, but didn't provide
    # it explicitly and no ipa was passed to grab it from), then fall back to the best guess, which is the train_version
    # of the most recently uploaded build
    app_version ||= latest_build.train_version

    # Sometimes latest build will disappear and a different build would get selected
    # Only set build if no latest build found or if same build versions as previously fetched build
    # Issue: https://github.com/fastlane/fastlane/issues/10945
    if build.nil? || (latest_build && latest_build.build_version == build.build_version && latest_build.train_version == app_version)
      build = latest_build
    end

    return build if build && build.processing == false

    if build
      UI.message("Waiting App Store Connect processing for build #{app_version} (#{build.build_version})... this might take a while...")
    else
      UI.message("Waiting App Store Connect processing for build... this might take a while...")
    end

    if (Time.now - start) > (60 * 5)
      UI.message("")
      UI.message("You can tweet: \"App Store Connect #iosprocessingtime #{((Time.now - start) / 60).round} minutes\"")
    end
    sleep(30)
  end
  nil
end