homebrew-core/Formula/doctl.rb
2019-08-18 02:08:27 +08:00

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.28.0.tar.gz"
sha256 "eafb41457c4fb279762b1a81606130bd8f02f0390df77b032d11108666daff49"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "0a01d082d153d1d7c705b1dcf6ea8077554d6ede9003b38337c0c8256c994c5d" => :mojave
sha256 "8a44b08591471addb194cbcefc3a7b109a7a5d1ac72421a5a3e079d87901625c" => :high_sierra
sha256 "dae9b623b2d28084b5ef86a65bdd5e79af1d29294513540d1d5b7066be57f485" => :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