homebrew-core/Formula/doctl.rb
2018-11-27 09:45:15 +01:00

41 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.12.0.tar.gz"
sha256 "15b0cf0dde2ad3cd14b0f5d6a61e84d8497ceb0a0d6981024b2298ab3c99869c"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "e1bd9ed6d74d4a5b78b5655afe7e0681b6c024d38d510ab7fa5530a44cbbe716" => :mojave
sha256 "d9174a7400823c233f4d2ebc0be79c683a53b2bbd904b99d8a166d0e4baf2ab7" => :high_sierra
sha256 "1cd9963ec80e2fa3e484063c4af855455874d33b14cb9c0a96de2cd0064d3a2a" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
mkdir_p buildpath/"src/github.com/digitalocean/"
ln_sf buildpath, buildpath/"src/github.com/digitalocean/doctl"
doctl_version = version.to_s.split(/\./)
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, "github.com/digitalocean/doctl/cmd/doctl"
bin.install "doctl"
(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