homebrew-core/Formula/doctl.rb
2019-08-02 04:33:00 +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.26.0.tar.gz"
sha256 "162194cae487c03a47c9a580683628c12b372a7fd8acf42fc2f18fefa1ff0e1c"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "7f71fde947deb304948d54fe5553aa146d4c58669085498db32239b4fa681a17" => :mojave
sha256 "fca3a61751a31f87260d29f3412b13bcea00c50288241c1ee16fa67c701e1b31" => :high_sierra
sha256 "a2dd912c778b0b3cf7117790b5dcad14d9c71265b7593613e08d82c08a568da6" => :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