homebrew-core/Formula/gitlab-runner.rb
2017-10-20 14:10:54 +01:00

110 lines
3.9 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.0.2",
:revision => "a9a76a502bf69371d9c610d0b2814b4e0f3ae762"
head "https://gitlab.com/gitlab-org/gitlab-runner.git"
bottle do
cellar :any_skip_relocation
sha256 "9b8b2af53eeb408919b4f03b3b7b3149a3c4404e723f476deaf38fd669d13651" => :high_sierra
sha256 "6cde0bde141d62dc76861170292773c9069ad7cc3216821e602b14017cf16b9b" => :sierra
sha256 "1cf5ccaad017703e4e3fbd8739703b77a59e6781181a69d8b3d56438c388f9f3" => :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.0.2/docker/prebuilt-x86_64.tar.xz",
:using => :nounzip
version "10.0.2"
sha256 "58c95075273f44ff926823aa9b5bf9fd4cb82c87adc27bef48d5bf985d629992"
end
resource "prebuilt-arm.tar.xz" do
url "https://gitlab-runner-downloads.s3.amazonaws.com/v10.0.2/docker/prebuilt-arm.tar.xz",
:using => :nounzip
version "10.0.2"
sha256 "b73a0690eef09c4f366342f98bec301020d47c16f98ac8a770f373dd81a76b04"
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