homebrew-core/Formula/doctl.rb
2019-08-03 07:38:26 +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.2.tar.gz"
sha256 "7635d26d8dd0d864fb372507afe99c7a70bb0937a6176d717393e333d92070d1"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "e4eed8ca401eb8504c587ce5ed067f29f308cfaaef43996bb93eb38290df4cdd" => :mojave
sha256 "228e571c521290dfaa2a127cf512c87dd3af97427f7659cb37b1891adab5a445" => :high_sierra
sha256 "4b0d7c48c788953a014a3c6979ec8df9a8990ba0474f53e2f0f6a7be3ac8190e" => :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