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 => "v11.11.1", :revision => "5a147c9271bc1f6114ed4e32d3ba3eb9ea372cda" head "https://gitlab.com/gitlab-org/gitlab-runner.git" bottle do cellar :any_skip_relocation sha256 "268779632107ce3452ef3475a9f708f4eab9fbbb6fa591899980e389578f92b0" => :mojave sha256 "715773cfadc77665d43cab49e471626caf77dd9d62d33a644f0a2df9569ebf91" => :high_sierra sha256 "46a79015b01db888b2e558f0efcf67eeb2baf14b7f5bef2f8c1151d102ad114d" => :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