homebrew-core/Formula/gitlab-runner.rb

82 lines
2.8 KiB
Ruby

class GitlabRunner < Formula
desc "Official GitLab CI runner"
homepage "https://gitlab.com/gitlab-org/gitlab-runner"
url "https://gitlab.com/gitlab-org/gitlab-runner.git",
tag: "v13.11.0",
revision: "7f7a4bb064e847bbd2196438d70fe82634141a00"
license "MIT"
head "https://gitlab.com/gitlab-org/gitlab-runner.git"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "87398a4188b6f36428cc656f9e19bd3ef99d09da60aa7ca00bdd9ea9d1cb2e8e"
sha256 cellar: :any_skip_relocation, big_sur: "71260b852ab3b8cc77aecf8aa374052df27c7aedc40a8847fc96fdd5d333d392"
sha256 cellar: :any_skip_relocation, catalina: "708fb716236df44bee70f7b42e5016fc50e604e0c3bab32deb9fa5cccb569abf"
sha256 cellar: :any_skip_relocation, mojave: "a6a2ef99b94599095547b8c36dea93bf2d10202fb92de54f7204ab51c77e6710"
end
depends_on "go" => :build
def install
dir = buildpath/"src/gitlab.com/gitlab-org/gitlab-runner"
dir.install buildpath.children
cd dir do
proj = "gitlab.com/gitlab-org/gitlab-runner"
system "go", "build", "-ldflags", <<~EOS
-X #{proj}/common.NAME=gitlab-runner
-X #{proj}/common.VERSION=#{version}
-X #{proj}/common.REVISION=#{Utils.git_short_head(length: 8)}
-X #{proj}/common.BRANCH=#{version.major}-#{version.minor}-stable
-X #{proj}/common.BUILT=#{Time.new.strftime("%Y-%m-%dT%H:%M:%S%:z")}
EOS
bin.install "gitlab-runner"
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