Class: Pilot::BuildManager

Inherits:
Manager
  • Object
show all
Defined in:
lib/pilot/build_manager.rb

Instance Attribute Summary

Attributes inherited from Manager

#config

Instance Method Summary collapse

Methods inherited from Manager

#app, #fetch_app_id, #fetch_app_identifier, #login, #start

Instance Method Details

#distribute(options, build = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pilot/build_manager.rb', line 39

def distribute(options, build = nil)
  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?
    builds = app.all_processing_builds + app.builds
    # 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

    UI.message("Distributing build #{build.train_version}(#{build.build_version}) from #{build.testing_status} -> External")
  end

  # First, set the changelog and/or description if necessary
  if 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
    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

  return if config[:skip_submission]
  distribute_build(build, options)
  UI.message("Successfully distributed build to beta testers 🚀")
end

#list(options) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/pilot/build_manager.rb', line 77

def list(options)
  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

  builds = app.all_processing_builds + app.builds
  # sort by upload_date
  builds.sort! { |a, b| a.upload_date <=> b.upload_date }
  rows = builds.collect { |build| describe_build(build) }

  puts Terminal::Table.new(
    title: "#{app.name} Builds".green,
    headings: ["Version #", "Build #", "Testing", "Installs", "Sessions"],
    rows: rows
  )
end

#upload(options) ⇒ Object



3
4
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
31
32
33
34
35
36
37
# File 'lib/pilot/build_manager.rb', line 3

def upload(options)
  start(options)

  UI.user_error!("No ipa file given") unless config[:ipa]

  UI.success("Ready to upload new build to TestFlight (App: #{app.apple_id})...")

  plist = FastlaneCore::IpaFileAnalyser.fetch_info_plist_file(config[:ipa]) || {}
  platform = plist["DTPlatformName"]
  platform = "ios" if platform == "iphoneos" # via https://github.com/fastlane/spaceship/issues/247
  package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate(app_id: app.apple_id,
                                                                  ipa_path: config[:ipa],
                                                              package_path: "/tmp",
                                                                  platform: platform)

  transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider])
  result = transporter.upload(app.apple_id, package_path)

  unless result
    UI.user_error!("Error uploading ipa file, for more information see above")
  end

  UI.message("Successfully uploaded the new binary to iTunes Connect")

  if config[:skip_waiting_for_build_processing]
    UI.important("Skip waiting for build processing")
    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 # this might take a while

  distribute(options, uploaded_build)
end