Class: Everywhere::Commands::PlatformRunner

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/everywhere/commands/platform/runner.rb

Overview

every platform runner — runs ON a build runner (a GitHub Actions macOS machine, or any Mac). It's the glue between the Runner API and the every release signing engine:

job spec → mark running → download+extract snapshot → pull JIT creds into
a throwaway keychain (+ .p8) → every release (streaming logs) → upload the
artifact + release.json → complete.

Authenticated with the per-artifact runner token, so it can only touch the one artifact it was dispatched for.

Instance Method Summary collapse

Instance Method Details

#call(artifact:, token:, url: nil, shell_dir: nil) ⇒ Object



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
# File 'lib/everywhere/commands/platform/runner.rb', line 33

def call(artifact:, token:, url: nil, shell_dir: nil, **)
  # We run headless on a build runner (a pipe, not a TTY) and stream into
  # the Platform web log, which renders ANSI. Force color on so the hosted
  # log reads like a local run.
  ENV["CLICOLOR_FORCE"] ||= "1" unless ENV["NO_COLOR"]

  base = Everywhere::Platform::Client.base_url(url)
  @client = Everywhere::Platform::Client.new(base, token: token)
  @artifact = artifact

  job = get!("/runner/artifacts/#{artifact}")
  patch!("/runner/artifacts/#{artifact}", status: "running")
  remote_log("picked up #{UI.cyan("#{job.dig("target", "os")}-#{job.dig("target", "arch")}")} for #{UI.bold(job.dig("app", "name"))}")

  Dir.mktmpdir("every-runner") do |work|
    src = fetch_snapshot(work, job)
    signing_env = pull_credentials(work)

    status, release_json, zip = run_release(src, job, signing_env, shell_dir)

    if status == "succeeded" && zip
      complete_success(zip, release_json)
    else
      complete_failure("build failed — see log")
    end
  ensure
    restore_keychains
  end
rescue Everywhere::Error => e
  complete_failure(e.message)
  UI.die!(e.message)
end