43 lines
1.5 KiB
Ruby
43 lines
1.5 KiB
Ruby
class Doctl < Formula
|
|
desc "Command-line tool for DigitalOcean"
|
|
homepage "https://github.com/digitalocean/doctl"
|
|
url "https://github.com/digitalocean/doctl/archive/v1.31.2.tar.gz"
|
|
sha256 "08b571db5f4b67c875b787014aad469b6355804be7406d714ea945816a039bb1"
|
|
head "https://github.com/digitalocean/doctl.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "91fd41dc09aff03e49ed94e9ff4a9939f68f696863b49d2302c3f83a8b39bf6b" => :mojave
|
|
sha256 "4af71a5b5ae91e044e3052beaf554d387379d87377029b29551e7ee92a2a13a7" => :high_sierra
|
|
sha256 "074eb0d986107ec8b541cafcb01580ba7510d962b0d82f06fe44ef979ef91a2b" => :sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GO111MODULE"] = "on"
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
doctl_version = version.to_s.split(/\./)
|
|
|
|
src = buildpath/"src/github.com/digitalocean/doctl"
|
|
src.install buildpath.children
|
|
src.cd do
|
|
base_flag = "-X github.com/digitalocean/doctl"
|
|
ldflags = %W[
|
|
#{base_flag}.Major=#{doctl_version[0]}
|
|
#{base_flag}.Minor=#{doctl_version[1]}
|
|
#{base_flag}.Patch=#{doctl_version[2]}
|
|
#{base_flag}.Label=release
|
|
].join(" ")
|
|
system "go", "build", "-ldflags", ldflags, "-o", bin/"doctl", "github.com/digitalocean/doctl/cmd/doctl"
|
|
end
|
|
|
|
(bash_completion/"doctl").write `#{bin}/doctl completion bash`
|
|
(zsh_completion/"doctl").write `#{bin}/doctl completion zsh`
|
|
end
|
|
|
|
test do
|
|
assert_match "doctl version #{version}-release", shell_output("#{bin}/doctl version")
|
|
end
|
|
end
|