1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Federico G. Schwindt d10c4f4f07 feat: add custom_block to brew formula generation (#906)
This allows authors to specify things such as devel, head and more.
See
https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md#advanced-formula-tricks
for details.
2018-12-30 00:06:54 -02:00

86 lines
1.5 KiB
Go

package brew
type templateData struct {
Name string
Desc string
Homepage string
DownloadURL string
Version string
Caveats []string
SHA256 string
Plist string
DownloadStrategy string
Install []string
Dependencies []string
Conflicts []string
Tests []string
CustomRequire string
CustomBlock []string
}
const formulaTemplate = `{{ if .CustomRequire -}}
require_relative "{{ .CustomRequire }}"
{{ end -}}
class {{ .Name }} < Formula
desc "{{ .Desc }}"
homepage "{{ .Homepage }}"
url "{{ .DownloadURL }}"
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
version "{{ .Version }}"
sha256 "{{ .SHA256 }}"
{{- with .CustomBlock }}
{{ range $index, $element := . }}
{{ . }}
{{- end }}
{{- end }}
{{- with .Dependencies }}
{{ range $index, $element := . }}
depends_on "{{ . }}"
{{- end }}
{{- end -}}
{{- with .Conflicts }}
{{ range $index, $element := . }}
conflicts_with "{{ . }}"
{{- end }}
{{- end }}
def install
{{- range $index, $element := .Install }}
{{ . -}}
{{- end }}
end
{{- with .Caveats }}
def caveats; <<~EOS
{{- range $index, $element := . }}
{{ . -}}
{{- end }}
EOS
end
{{- end -}}
{{- with .Plist }}
plist_options :startup => false
def plist; <<~EOS
{{ . }}
EOS
end
{{- end -}}
{{- if .Tests }}
test do
{{- range $index, $element := .Tests }}
{{ . -}}
{{- end }}
end
{{- end }}
end
`