homebrew-core/Formula/doctl.rb
2017-05-18 08:20:54 -07:00

38 lines
1.3 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.6.1.tar.gz"
sha256 "af3415f735165aa948f6d40fd03591e22993867828db1370d5717c5e9680dadf"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "b47e2428837da2b369081b36985b893438b862c472da08fa007f0d0ae3be6750" => :sierra
sha256 "e1d92210c84fcd475dcacb7b031a6422ac49a73454eceeebc672743640894dff" => :el_capitan
sha256 "7d6e9f845e3496b3df3280658b67a4edd70592c53358907af1c193f149d01de0" => :yosemite
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"
end
test do
assert_match "doctl version #{version}-release", shell_output("#{bin}/doctl version")
end
end