homebrew-core/Formula/gitlab-runner.rb
2018-09-01 21:37:46 +10:00

76 lines
2.6 KiB
Ruby

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 => "v11.2.0",
:revision => "35e8515d8af4d757f39f50cda7e17a9de131ffbf"
revision 1
head "https://gitlab.com/gitlab-org/gitlab-runner.git"
bottle do
cellar :any_skip_relocation
sha256 "c0dacec72b6db2064771283b4c05de93f20b49f7a9d959c3b56b0bb8e7201d16" => :mojave
sha256 "b20fffbe52ae1a1b24a5142d5ae414cc42972d4ca03098982eff586e94fa6598" => :high_sierra
sha256 "1812672ba85471a9ce4cccd83a714265c167c3c7e781db6b64ba96b27f7d41a2" => :sierra
sha256 "b0e8578966ada7d00a21dfa1e40ff90b84f054edcb87f4ee05d245e4d59fae9c" => :el_capitan
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/gitlab.com/gitlab-org/gitlab-runner"
dir.install buildpath.children
cd dir do
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