mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-26 04:22:05 +02:00
b4f154d81f
* fix: improving URLs on linuxbrew Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: rename template fields Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix(tests): adapts brew test formulas and docs * Revert "fix(tests): adapts brew test formulas and docs" This reverts commit 51dd8cf6c71ebc262661d0fb9cd43946bf4cfdb2. * fix: template Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * docs: fixed example Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Manuel Vogel <mavogel@posteo.de>
138 lines
3.0 KiB
Go
138 lines
3.0 KiB
Go
package brew
|
|
|
|
import "github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
type templateData struct {
|
|
Name string
|
|
Desc string
|
|
Homepage string
|
|
Version string
|
|
Caveats []string
|
|
Plist string
|
|
DownloadStrategy string
|
|
Install []string
|
|
PostInstall string
|
|
Dependencies []config.HomebrewDependency
|
|
Conflicts []string
|
|
Tests []string
|
|
CustomRequire string
|
|
CustomBlock []string
|
|
MacOS downloadable
|
|
LinuxAmd64 downloadable
|
|
LinuxArm downloadable
|
|
LinuxArm64 downloadable
|
|
}
|
|
|
|
type downloadable struct {
|
|
DownloadURL string
|
|
SHA256 string
|
|
}
|
|
|
|
const formulaTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
|
|
{{ if .CustomRequire -}}
|
|
require_relative "{{ .CustomRequire }}"
|
|
{{ end -}}
|
|
class {{ .Name }} < Formula
|
|
desc "{{ .Desc }}"
|
|
homepage "{{ .Homepage }}"
|
|
version "{{ .Version }}"
|
|
bottle :unneeded
|
|
{{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }}
|
|
depends_on :linux
|
|
{{- end }}
|
|
{{- printf "\n" }}
|
|
{{- if .MacOS.DownloadURL }}
|
|
if OS.mac?
|
|
url "{{ .MacOS.DownloadURL }}"
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
sha256 "{{ .MacOS.SHA256 }}"
|
|
end
|
|
{{- 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 }}
|
|
|
|
{{- with .CustomBlock }}
|
|
{{ range $index, $element := . }}
|
|
{{ . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{- with .Dependencies }}
|
|
{{ range $index, $element := . }}
|
|
depends_on "{{ .Name }}"
|
|
{{- if .Type }} => :{{ .Type }}{{- end }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
|
|
{{- with .Conflicts }}
|
|
{{ range $index, $element := . }}
|
|
conflicts_with "{{ . }}"
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
def install
|
|
{{- range $index, $element := .Install }}
|
|
{{ . -}}
|
|
{{- end }}
|
|
end
|
|
|
|
{{- with .PostInstall }}
|
|
|
|
def post_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
|
|
`
|