homebrew-core/Formula/doctl.rb
2017-10-31 23:25:41 -04: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.7.1.tar.gz"
sha256 "6c47b5ce9c4739499732be96b914cecbad9135088504351601b75a9608d19d64"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "324531ba538d2960e1580595a6fe16903902eadb04b339c85f156f935a60cce9" => :high_sierra
sha256 "8e6647bddaf162ac190de923f9eb0321e90e3022b017cf5c18f235e155a6e38f" => :sierra
sha256 "610df50fff53be73902d687e7ab052549d235c6410d48c9b8ffcaa4bb90d96e7" => :el_capitan
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