homebrew-core/Formula/doctl.rb
2019-09-29 20:14:48 +02:00

42 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.32.2.tar.gz"
sha256 "b82d9d09962b233931badbf861e146edac212eacc57b6a89d9c45129522250c7"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "45fa344a95e58d515af468e250c2aea2956c918efba465801f446c4eb879addf" => :catalina
sha256 "3ba8e427b0e669e501182dfbceee1ec8d28d7283c071cc01815ff14132d6509c" => :mojave
sha256 "9670ab5c32fdcf16f7235ecd22037eb6b29f888ab277123db14b5cde36b9a646" => :high_sierra
end
depends_on "go" => :build
def install
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