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.7.1", :revision => "b9bba623e845cccf3488db85e35ecfefd2639899" head "https://gitlab.com/gitlab-org/gitlab-runner.git" bottle do cellar :any_skip_relocation sha256 "aca0e8bce7cdc70110ade2229e4c3209592ec04937a684350c077e9e7f8a4d69" => :high_sierra sha256 "75dd508e837760f8cc4fdaa1843071328ffabc3a044262414e66e7a7a391ddde" => :sierra sha256 "dae1b19d5ea5105ed41093f28971998c46b917dd6ad7d500de4f011d37f3d338" => :el_capitan end depends_on "go" => :build depends_on "go-bindata" => :build depends_on "docker" => :recommended resource "prebuilt-x86_64.tar.xz" do url "https://gitlab-runner-downloads.s3.amazonaws.com/v10.7.1/docker/prebuilt-x86_64.tar.xz", :using => :nounzip version "10.7.1" sha256 "8591f5fad5722db0eb97f9afa79abdda7b7e4a59b83497e1503626ba3f4b716f" end resource "prebuilt-arm.tar.xz" do url "https://gitlab-runner-downloads.s3.amazonaws.com/v10.7.1/docker/prebuilt-arm.tar.xz", :using => :nounzip version "10.7.1" sha256 "0669115b8447d965cf77fa97eef324d9db023c736dafaafe3f3df9f2b52a68ed" end def install ENV["GOPATH"] = buildpath dir = buildpath/"src/gitlab.com/gitlab-org/gitlab-runner" dir.install buildpath.children 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 SessionCreate KeepAlive RunAtLoad Disabled Label #{plist_name} ProgramArguments #{opt_bin}/gitlab-runner run --working-directory #{ENV["HOME"]} --config #{ENV["HOME"]}/.gitlab-runner/config.toml --service gitlab-runner --syslog EOS end test do assert_match version.to_s, shell_output("#{bin}/gitlab-runner --version") end end