Class: Fastlane::Actions::PharenUploadBuildAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



68
69
70
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 68

def self.authors
  ["Pharen (Lucubra LLC)"]
end

.available_optionsObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 81

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ipa,
                                 env_name: "PHAREN_IPA",
                                 description: "Path to the .ipa. Defaults to what gym/build_app left in the lane context",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :pharen_binary,
                                 env_name: "PHAREN_BINARY",
                                 description: "Command that invokes the Pharen CLI (may include arguments, e.g. `node /path/to/cli.js`)",
                                 optional: true,
                                 default_value: "pharen",
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :strict,
                                 env_name: "PHAREN_STRICT",
                                 description: "Fail the lane on error (true) instead of warning and continuing (false)",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



64
65
66
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 64

def self.description
  "Upload the IPA to Pharen dl distribution and return the OTA install link (zero-arg after gym)"
end

.detailsObject



72
73
74
75
76
77
78
79
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 72

def self.details
  "Thin wrapper over `pharen upload-build`: the IPA defaults from " \
    "SharedValues::IPA_OUTPUT_PATH; version, build number and bundle id are " \
    "extracted from the IPA's Info.plist so nothing needs passing. The server " \
    "owns the dl layout, opaque slug and manifest.plist; the returned " \
    "install_url is this action's return value and lands in " \
    "lane_context[SharedValues::PHAREN_INSTALL_URL]."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 113

def self.is_supported?(platform)
  platform == :ios
end

.outputObject



103
104
105
106
107
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 103

def self.output
  [
    ["PHAREN_INSTALL_URL", "The itms-services install link answered by the Pharen control plane"]
  ]
end

.return_valueObject



109
110
111
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 109

def self.return_value
  "The install_url string on success; nil on skipped/failed-but-not-strict"
end

.run(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/pharen/actions/pharen_upload_build_action.rb', line 19

def self.run(params)
  helper = Helper::PharenHelper

  ipa = params[:ipa] || Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]
  if ipa.nil? || ipa.to_s.empty?
    helper.fail_or_warn(
      params[:strict],
      "pharen_upload_build: no IPA — run after build_app/gym, or pass ipa:"
    )
    return nil
  end
  ipa = File.expand_path(ipa.to_s)

  begin
    info = helper.read_ipa_info(ipa)
  rescue Helper::PharenHelper::Failure => e
    helper.fail_or_warn(params[:strict], "pharen_upload_build: #{e.message}")
    return nil
  end

  args = [
    "upload-build",
    "--platform", "ios",
    "--version", info[:version],
    "--build", info[:build],
    "--bundle-id", info[:bundle_id],
    ipa
  ]
  result = helper.run_pharen(params[:pharen_binary], args)
  unless result[:ok]
    helper.fail_or_warn(params[:strict], helper.cli_failure_message("pharen upload-build", result))
    return nil
  end

  install_url = result[:json].is_a?(Hash) ? result[:json]["install_url"] : nil
  Actions.lane_context[SharedValues::PHAREN_INSTALL_URL] = install_url if install_url
  UI.success("pharen_upload_build: uploaded #{info[:version]} (#{info[:build]}) #{info[:bundle_id]}")
  UI.important("Install (Safari on the phone): #{install_url}") if install_url
  install_url
end