2017-07-16 15:06:32 -03:00
|
|
|
package brew
|
|
|
|
|
2020-05-24 18:10:25 +03:00
|
|
|
import "github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
|
2017-07-16 15:06:32 -03:00
|
|
|
type templateData struct {
|
2018-06-20 09:46:42 -03:00
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
Homepage string
|
|
|
|
Version string
|
2020-11-26 14:06:47 +01:00
|
|
|
License string
|
2018-06-20 09:46:42 -03:00
|
|
|
Caveats []string
|
|
|
|
Plist string
|
|
|
|
DownloadStrategy string
|
|
|
|
Install []string
|
2020-09-18 10:42:52 -03:00
|
|
|
PostInstall string
|
2020-05-24 18:10:25 +03:00
|
|
|
Dependencies []config.HomebrewDependency
|
2018-06-20 09:46:42 -03:00
|
|
|
Conflicts []string
|
|
|
|
Tests []string
|
2018-11-21 15:57:44 +00:00
|
|
|
CustomRequire string
|
2018-12-30 02:06:54 +00:00
|
|
|
CustomBlock []string
|
2019-06-10 10:35:19 -03:00
|
|
|
MacOS downloadable
|
2020-11-16 09:16:50 -03:00
|
|
|
LinuxAmd64 downloadable
|
|
|
|
LinuxArm downloadable
|
|
|
|
LinuxArm64 downloadable
|
2019-06-10 10:35:19 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
type downloadable struct {
|
|
|
|
DownloadURL string
|
|
|
|
SHA256 string
|
2017-07-16 15:06:32 -03:00
|
|
|
}
|
|
|
|
|
2019-01-27 16:37:32 -02:00
|
|
|
const formulaTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
|
|
|
|
{{ if .CustomRequire -}}
|
2018-11-21 15:57:44 +00:00
|
|
|
require_relative "{{ .CustomRequire }}"
|
|
|
|
{{ end -}}
|
|
|
|
class {{ .Name }} < Formula
|
2017-07-16 15:06:32 -03:00
|
|
|
desc "{{ .Desc }}"
|
|
|
|
homepage "{{ .Homepage }}"
|
|
|
|
version "{{ .Version }}"
|
2020-11-26 14:06:47 +01:00
|
|
|
{{ if .License -}}
|
|
|
|
license "{{ .License }}"
|
|
|
|
{{ end -}}
|
2019-07-20 14:27:25 -03:00
|
|
|
bottle :unneeded
|
2020-11-16 09:16:50 -03:00
|
|
|
{{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }}
|
|
|
|
depends_on :linux
|
|
|
|
{{- end }}
|
|
|
|
{{- printf "\n" }}
|
|
|
|
{{- if .MacOS.DownloadURL }}
|
2019-06-10 10:35:19 -03:00
|
|
|
if OS.mac?
|
|
|
|
url "{{ .MacOS.DownloadURL }}"
|
2019-08-13 19:37:11 +03:00
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
2019-06-10 10:35:19 -03:00
|
|
|
sha256 "{{ .MacOS.SHA256 }}"
|
|
|
|
end
|
2020-11-16 09:16:50 -03:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- if .LinuxAmd64.DownloadURL }}
|
|
|
|
if OS.linux? && Hardware::CPU.intel?
|
|
|
|
url "{{ .LinuxAmd64.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .LinuxAmd64.SHA256 }}"
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- if .LinuxArm.DownloadURL }}
|
|
|
|
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
|
|
|
url "{{ .LinuxArm.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .LinuxArm.SHA256 }}"
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- if .LinuxArm64.DownloadURL }}
|
|
|
|
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
|
|
|
url "{{ .LinuxArm64.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .LinuxArm64.SHA256 }}"
|
|
|
|
end
|
|
|
|
{{- end }}
|
2019-06-10 10:35:19 -03:00
|
|
|
|
2018-12-30 02:06:54 +00:00
|
|
|
{{- with .CustomBlock }}
|
|
|
|
{{ range $index, $element := . }}
|
|
|
|
{{ . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2018-04-03 21:13:17 -03:00
|
|
|
{{- with .Dependencies }}
|
|
|
|
{{ range $index, $element := . }}
|
2020-05-24 18:10:25 +03:00
|
|
|
depends_on "{{ .Name }}"
|
|
|
|
{{- if .Type }} => :{{ .Type }}{{- end }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Conflicts }}
|
|
|
|
{{ range $index, $element := . }}
|
2017-07-16 15:06:32 -03:00
|
|
|
conflicts_with "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
|
2020-09-18 10:42:52 -03:00
|
|
|
{{- with .PostInstall }}
|
|
|
|
|
|
|
|
def post_install
|
|
|
|
{{ . }}
|
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Caveats }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-05 13:38:32 -07:00
|
|
|
def caveats; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- range $index, $element := . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Plist }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
|
|
|
plist_options :startup => false
|
|
|
|
|
2018-02-06 10:08:20 -08:00
|
|
|
def plist; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{ . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Tests }}
|
|
|
|
|
|
|
|
test do
|
|
|
|
{{- range $index, $element := .Tests }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
`
|