homebrew-core/Formula/gitlab-runner.rb
2017-12-22 08:24:08 -08:00

109 lines
3.8 KiB
Ruby

require "language/go"
class GitlabRunner < Formula
desc "The official GitLab CI runner written in Go"
homepage "https://gitlab.com/gitlab-org/gitlab-runner"
url "https://gitlab.com/gitlab-org/gitlab-runner.git",
:tag => "v10.3.0",
:revision => "5cf5e19ad20e4d9710855063ad1dc572e4faa2f8"
head "https://gitlab.com/gitlab-org/gitlab-runner.git"
bottle do
sha256 "446804484f78a31983402d4d9e3177a18abc724eaa36f00609e617077d9b6382" => :high_sierra
sha256 "cbf82c4f1e16758c33208fdd93bc2996b01aaba9e44e19e3d982ae5a49febdb4" => :sierra
sha256 "4566f9e6631580bc963b7f21199e19822d66214cd039af7f9020e9f158006baa" => :el_capitan
end
depends_on "go" => :build
depends_on "docker" => :recommended
go_resource "github.com/jteeuwen/go-bindata" do
url "https://github.com/jteeuwen/go-bindata.git",
:revision => "a0ff2567cfb70903282db057e799fd826784d41d"
end
resource "prebuilt-x86_64.tar.xz" do
url "https://gitlab-runner-downloads.s3.amazonaws.com/v10.3.0/docker/prebuilt-x86_64.tar.xz",
:using => :nounzip
version "10.3.0"
sha256 "5b46b9fc173378ef2cf7f58ffecd40f2cbc62b60b86ff49d2d91dace45ef1d5a"
end
resource "prebuilt-arm.tar.xz" do
url "https://gitlab-runner-downloads.s3.amazonaws.com/v10.3.0/docker/prebuilt-arm.tar.xz",
:using => :nounzip
version "10.3.0"
sha256 "91cc4703e52c3b77c9df8c4820d45dfea2f78edde3815064d265a64b7e8d4c49"
end
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/gitlab.com/gitlab-org/gitlab-runner"
dir.install buildpath.children
ENV.prepend_create_path "PATH", buildpath/"bin"
Language::Go.stage_deps resources, buildpath/"src"
cd "src/github.com/jteeuwen/go-bindata/go-bindata" do
system "go", "install"
end
cd dir do
Pathname.pwd.install resource("prebuilt-x86_64.tar.xz"),
resource("prebuilt-arm.tar.xz")
system "go-bindata", "-pkg", "docker", "-nocompress", "-nomemcopy",
"-nometadata", "-o",
"#{dir}/executors/docker/bindata.go",
"prebuilt-x86_64.tar.xz",
"prebuilt-arm.tar.xz"
proj = "gitlab.com/gitlab-org/gitlab-runner"
commit = Utils.popen_read("git", "rev-parse", "--short", "HEAD").chomp
branch = version.to_s.split(".")[0..1].join("-") + "-stable"
built = Time.new.strftime("%Y-%m-%dT%H:%M:%S%:z")
system "go", "build", "-ldflags", <<~EOS
-X #{proj}/common.NAME=gitlab-runner
-X #{proj}/common.VERSION=#{version}
-X #{proj}/common.REVISION=#{commit}
-X #{proj}/common.BRANCH=#{branch}
-X #{proj}/common.BUILT=#{built}
EOS
bin.install "gitlab-runner"
prefix.install_metafiles
end
end
plist_options :manual => "gitlab-runner start"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SessionCreate</key><false/>
<key>KeepAlive</key><true/>
<key>RunAtLoad</key><true/>
<key>Disabled</key><false/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/gitlab-runner</string>
<string>run</string>
<string>--working-directory</string>
<string>#{ENV["HOME"]}</string>
<string>--config</string>
<string>#{ENV["HOME"]}/.gitlab-runner/config.toml</string>
<string>--service</string>
<string>gitlab-runner</string>
<string>--syslog</string>
</array>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/gitlab-runner --version")
end
end