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.5.1", :revision => "7f00c780e2a2411ce04d0d55979490918255ea76" head "https://gitlab.com/gitlab-org/gitlab-runner.git" bottle do cellar :any_skip_relocation sha256 "9e6ac5ee7121e07456c1c0f7f3946724cbd2339a79803044d47f98a5c2037c85" => :mojave sha256 "4fabaaf4f414287aa6ab440e1f19a237e04434f3854758131842ad48859390dd" => :high_sierra sha256 "3d1d08dfe594d4f66834ec19625166a6eab39b59d2b3f45bc5bb8ecd95695830" => :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 EOS end test do assert_match version.to_s, shell_output("#{bin}/gitlab-runner --version") end end