-
Notifications
You must be signed in to change notification settings - Fork 4
/
autify-cli.rb
55 lines (49 loc) · 1.64 KB
/
autify-cli.rb
1
2
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# CAVEAT: Do not modify this file manually.
# This file is auto-generated by GitHub Actions of autify-cli.
# Edit https://github.com/autifyhq/autify-cli/blob/main/autify-cli.rb instead.
class AutifyCli < Formula
desc "Autify Command-Line Interface (CLI)"
homepage "https://github.com/autifyhq/autify-cli"
url "https://github.com/autifyhq/autify-cli", using: :git, revision: "<REVISION>"
version "<VERSION>"
# sha256 ""
license "MIT"
def install
system "curl #{taball_url} | tar xz"
inreplace "autify/bin/autify", /^CLIENT_HOME=/, "export AUTIFY_OCLIF_CLIENT_HOME=#{lib}/client\nCLIENT_HOME="
libexec.install Dir["autify/*"]
bin.install_symlink libexec/"bin"/"autify"
end
test do
assert_match "autify-cli/#{version}", shell_output("#{bin}/autify --version")
end
private
def taball_url
package = JSON.parse(File.read("./package.json"), symbolize_names: true)
raise "Version mismatch: #{package[:version]}" if package[:version] != version
bucket = package.dig(:oclif, :update, :s3, :bucket)
folder = package.dig(:oclif, :update, :s3, :folder)
sha = `git rev-parse --short HEAD`.strip
uname_os = `uname`.strip
os = case uname_os
when /darwin/i
"darwin"
when /linux/i
"linux"
else
raise "Unsupported os: #{uname_os}"
end
uname_arch = `uname -m`.strip
arch = case uname_arch
when /x86_64/i
"x64"
when /aarch/i
"arm"
when /arm64/i
"arm64"
else
raise "Unsupported arch: #{uname_arch}"
end
"https://#{bucket}.s3.amazonaws.com/#{folder}/versions/#{version}/#{sha}/autify-v#{version}-#{sha}-#{os}-#{arch}.tar.gz"
end
end