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.0.1", :revision => "0e5417a3db61d25367e4951ac0d2ef9242509796" head "https://gitlab.com/gitlab-org/gitlab-runner.git" bottle do cellar :any_skip_relocation sha256 "f076d76494a5fb78720975ca5e0952b02aa9ae885e25e928dd4e7c43e04c5a34" => :mojave sha256 "ca26d786db80449ef5a1a998b7943b20fbfbfa63c87c91b03bd6ab88ea6c7445" => :high_sierra sha256 "a149eb7de7fdac4ca65d6fb3dcfcdb108dce7255f95c9084d1aa63046ae5d7ee" => :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 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 EnvironmentVariables PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin EOS end test do assert_match version.to_s, shell_output("#{bin}/gitlab-runner --version") end end