43 lines
1.5 KiB
Ruby
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.38.0.tar.gz"
|
|
sha256 "4607b952358edf214e7fc80409646f16860367394860ab8405d19c15803209a1"
|
|
head "https://github.com/digitalocean/doctl.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "90542688d28756af7d1dc623b78516022072e5eb0fe8ef04b22bff852cce7c85" => :catalina
|
|
sha256 "e395c27bfd1584a61791c1aec6ffb692b0836856eba8c15a7e617df332995593" => :mojave
|
|
sha256 "594048d1929511018081dca35eddcb02a90291e8450f7a9479bb69f3ebbad883" => :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
|