github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/pipeline/brew/template.go (about) 1 package brew 2 3 import "github.com/goreleaser/goreleaser/config" 4 5 type templateData struct { 6 Name string 7 Desc string 8 Homepage string 9 DownloadURL string 10 Repo config.Repo // FIXME: will not work for anything but github right now. 11 Tag string 12 Version string 13 Caveats []string 14 File string 15 SHA256 string 16 Plist string 17 DownloadStrategy string 18 Install []string 19 Dependencies []string 20 BuildDependencies []string 21 Conflicts []string 22 Tests []string 23 } 24 25 const formulaTemplate = `class {{ .Name }} < Formula 26 desc "{{ .Desc }}" 27 homepage "{{ .Homepage }}" 28 {{ if .BuildDependencies -}} 29 url "{{ .DownloadURL }}/{{ .Repo.Owner }}/{{ .Repo.Name }}/archive/{{ .Tag }}.tar.gz" 30 head "https://github.com/{{ .Repo.Owner }}/{{ .Repo.Name }}.git" 31 {{- else -}} 32 url "{{ .DownloadURL }}/{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}" 33 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 34 {{- end }} 35 version "{{ .Version }}" 36 sha256 "{{ .SHA256 }}" 37 38 {{- with .Dependencies }} 39 {{ range $index, $element := . }} 40 depends_on "{{ . }}" 41 {{- end }} 42 {{- end -}} 43 {{- with .BuildDependencies -}} 44 {{ range $index, $element := . }} 45 depends_on "{{ . }}" => :build 46 {{- end }} 47 {{- end -}} 48 49 {{- with .Conflicts }} 50 {{ range $index, $element := . }} 51 conflicts_with "{{ . }}" 52 {{- end }} 53 {{- end }} 54 55 def install 56 {{- range $index, $element := .Install }} 57 {{ . -}} 58 {{- end }} 59 end 60 61 {{- with .Caveats }} 62 63 def caveats; <<~EOS 64 {{- range $index, $element := . }} 65 {{ . -}} 66 {{- end }} 67 EOS 68 end 69 {{- end -}} 70 71 {{- with .Plist }} 72 73 plist_options :startup => false 74 75 def plist; <<~EOS 76 {{ . }} 77 EOS 78 end 79 {{- end -}} 80 81 {{- if .Tests }} 82 83 test do 84 {{- range $index, $element := .Tests }} 85 {{ . -}} 86 {{- end }} 87 end 88 {{- end }} 89 end 90 `