Class: Everywhere::Commands::Publish

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

Overview

Publish a released build to the app's update bucket — the free, self-hosted half of auto-updates. Reads the receipt every release wrote, signs the artifact, uploads it plus the manifests to any S3-compatible bucket, and cuts latest.json over LAST so shipped apps only ever see a complete release.

Bucket creds come from the standard AWS env vars; endpoint/bucket/etc. from everywhere.yml's updates.s3 section. See UpdateManifest for the layout/JSON contract.

Constant Summary collapse

CONTENT_TYPES =

Only the .apk needs a specific type: Android refuses to install a download the server labelled application/octet-stream.

{
  ".zip" => "application/zip",
  ".apk" => "application/vnd.android.package-archive",
  ".aab" => "application/octet-stream",
  ".ipa" => "application/octet-stream"
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(root: ".", receipt: nil, channel: nil, notes: nil, notes_file: nil, key: nil, rollback_to: nil, latest_alias: true, force: false) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/everywhere/commands/publish.rb', line 46

def call(root: ".", receipt: nil, channel: nil, notes: nil, notes_file: nil, key: nil,
         rollback_to: nil, latest_alias: true, force: false, **)
  @root = File.expand_path(root)
  @config = Everywhere::Config.load(@root)
  @channel = channel || @config.updates_channel
  preflight!

  if rollback_to
    rollback!(rollback_to, latest_alias: latest_alias)
  else
    publish!(receipt_path(receipt), notes: read_notes(notes, notes_file),
             key: key, latest_alias: latest_alias, force: force)
  end
rescue Everywhere::S3::Error => e
  # RequestTimeExpired means the bucket rejected our SigV4 timestamp; the
  # only realistic local cause is a wrong clock, and the raw message
  # doesn't say so.
  hint = e.message.include?("RequestTimeExpired") ? " — your system clock may be off by more than 15 minutes" : ""
  UI.die!("#{e.message}#{hint}")
end