Class: Fastlane::Actions::PharenReleaseAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



121
122
123
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 121

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

.available_optionsObject



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 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 134

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: :dsym_paths,
                                 env_name: "PHAREN_DSYM_PATHS",
                                 description: "dSYM bundles/zips to upload. Defaults to gym's DSYM_OUTPUT_PATH + download_dsyms' DSYM_PATHS",
                                 optional: true,
                                 is_string: false),
    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 any step's error (true) instead of warning and continuing (false)",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



117
118
119
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 117

def self.description
  "One call after build_app: register the release, upload symbols + build to Pharen, return the install link"
end

.detailsObject



125
126
127
128
129
130
131
132
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 125

def self.details
  "Orchestrates the Pharen CLI's three steps (releases new → upload-symbols → " \
    "upload-build) with everything derived: IPA + dSYMs from the lane context, " \
    "version/build/bundle id from the IPA's Info.plist, commit sha from git, " \
    "org/app from the committed .pharen.yml, auth from PHAREN_AUTH_TOKEN. " \
    "Missing dSYMs warn LOUDLY (or abort under strict) — a build without " \
    "symbols ships crashes that can never be read."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 171

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

.outputObject



161
162
163
164
165
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 161

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

.return_valueObject



167
168
169
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 167

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

.run(params) ⇒ Object



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
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
106
107
108
109
110
111
# File 'lib/fastlane/plugin/pharen/actions/pharen_release_action.rb', line 31

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

  # -- gather: IPA + identity (the customer passes nothing) --------------------
  ipa = params[:ipa] || Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]
  if ipa.nil? || ipa.to_s.empty?
    helper.fail_or_warn(params[:strict], "pharen_release: 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_release: #{e.message}")
    return nil
  end

  # -- step 1: register the release (idempotent server-side; commit = provenance)
  release_args = ["releases", "new", "--platform", "ios", "--version", info[:version], "--build", info[:build]]
  sha = helper.git_commit_sha
  release_args += ["--commit", sha] if sha
  release = helper.run_pharen(params[:pharen_binary], release_args)
  unless release[:ok]
    # Not fatal in warn mode: ingest also binds releases lazily, so a failed
    # registration degrades provenance, not the pipeline.
    helper.fail_or_warn(params[:strict], helper.cli_failure_message("pharen releases new", release))
    return nil if params[:strict]
  end

  # -- step 2: symbols (every dSYM the lane produced) ---------------------------
  dsym_inputs = params[:dsym_paths]
  if dsym_inputs.nil? || Array(dsym_inputs).empty?
    candidates = []
    candidates << Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]
    candidates.concat(Array(Actions.lane_context[SharedValues::DSYM_PATHS]))
    dsym_inputs = candidates.compact.uniq
  end
  if Array(dsym_inputs).empty?
    helper.fail_or_warn(
      params[:strict],
      "pharen_release: no dSYMs in the lane context — crashes from this build " \
        "can NEVER symbolicate. Archive with DEBUG_INFORMATION_FORMAT=dwarf-with-dsym, " \
        "or pass dsym_paths:"
    )
  else
    begin
      dsyms = helper.expand_dsym_inputs(dsym_inputs)
      symbols = helper.run_pharen(params[:pharen_binary], ["upload-symbols", *dsyms])
      if symbols[:ok]
        summary = symbols[:json].is_a?(Hash) ? symbols[:json]["summary"] : nil
        UI.success("pharen_release: symbols — #{summary || "uploaded #{dsyms.length} dSYM(s)"}")
      else
        helper.fail_or_warn(params[:strict], helper.cli_failure_message("pharen upload-symbols", symbols))
      end
    rescue Helper::PharenHelper::Failure => e
      helper.fail_or_warn(params[:strict], "pharen_release: #{e.message}")
    end
  end

  # -- step 3: the build itself → install link ----------------------------------
  build_args = [
    "upload-build",
    "--platform", "ios",
    "--version", info[:version],
    "--build", info[:build],
    "--bundle-id", info[:bundle_id],
    ipa
  ]
  build = helper.run_pharen(params[:pharen_binary], build_args)
  unless build[:ok]
    helper.fail_or_warn(params[:strict], helper.cli_failure_message("pharen upload-build", build))
    return nil
  end

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