homebrew-core/Formula/gitlab-runner.rb
2019-10-30 22:56:11 -04:00

79 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 => "v12.4.1",
:revision => "05161b14c906e862455a2a9a8c3e549379af6bba"
head "https://gitlab.com/gitlab-org/gitlab-runner.git"
bottle do
cellar :any_skip_relocation
sha256 "77d99ef3cfebda7ab4fab55d68f88d1fb7f5cdd85ea51871cbe5e35a94a8f664" => :catalina
sha256 "6a4c1bddbc26933ae64a0ae61b365da5872f6eaff342dac39d078e2ebe4734fc" => :mojave
sha256 "3e2ac5d8036242c9f39263e76f97ce38b5dc1dbf22c31819ef3d7f32fce36a02" => :high_sierra
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>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/gitlab-runner --version")
end
end