github.com/amane3/goreleaser@v0.182.0/internal/pipe/brew/template.go (about) 1 package brew 2 3 import "github.com/amane3/goreleaser/pkg/config" 4 5 type templateData struct { 6 Name string 7 Desc string 8 Homepage string 9 Version string 10 License string 11 Caveats []string 12 Plist string 13 DownloadStrategy string 14 Install []string 15 PostInstall string 16 Dependencies []config.HomebrewDependency 17 Conflicts []string 18 Tests []string 19 CustomRequire string 20 CustomBlock []string 21 MacOS downloadable 22 LinuxAmd64 downloadable 23 LinuxArm downloadable 24 LinuxArm64 downloadable 25 } 26 27 type downloadable struct { 28 DownloadURL string 29 SHA256 string 30 } 31 32 const formulaTemplate = `# This file was generated by GoReleaser. DO NOT EDIT. 33 {{ if .CustomRequire -}} 34 require_relative "{{ .CustomRequire }}" 35 {{ end -}} 36 class {{ .Name }} < Formula 37 desc "{{ .Desc }}" 38 homepage "{{ .Homepage }}" 39 version "{{ .Version }}" 40 {{ if .License -}} 41 license "{{ .License }}" 42 {{ end -}} 43 bottle :unneeded 44 {{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }} 45 depends_on :linux 46 {{- end }} 47 {{- printf "\n" }} 48 {{- if .MacOS.DownloadURL }} 49 if OS.mac? 50 url "{{ .MacOS.DownloadURL }}" 51 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 52 sha256 "{{ .MacOS.SHA256 }}" 53 end 54 {{- end }} 55 56 {{- if .LinuxAmd64.DownloadURL }} 57 if OS.linux? && Hardware::CPU.intel? 58 url "{{ .LinuxAmd64.DownloadURL }}" 59 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 60 sha256 "{{ .LinuxAmd64.SHA256 }}" 61 end 62 {{- end }} 63 64 {{- if .LinuxArm.DownloadURL }} 65 if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? 66 url "{{ .LinuxArm.DownloadURL }}" 67 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 68 sha256 "{{ .LinuxArm.SHA256 }}" 69 end 70 {{- end }} 71 72 {{- if .LinuxArm64.DownloadURL }} 73 if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit? 74 url "{{ .LinuxArm64.DownloadURL }}" 75 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 76 sha256 "{{ .LinuxArm64.SHA256 }}" 77 end 78 {{- end }} 79 80 {{- with .CustomBlock }} 81 {{ range $index, $element := . }} 82 {{ . }} 83 {{- end }} 84 {{- end }} 85 86 {{- with .Dependencies }} 87 {{ range $index, $element := . }} 88 depends_on "{{ .Name }}" 89 {{- if .Type }} => :{{ .Type }}{{- end }} 90 {{- end }} 91 {{- end -}} 92 93 {{- with .Conflicts }} 94 {{ range $index, $element := . }} 95 conflicts_with "{{ . }}" 96 {{- end }} 97 {{- end }} 98 99 def install 100 {{- range $index, $element := .Install }} 101 {{ . -}} 102 {{- end }} 103 end 104 105 {{- with .PostInstall }} 106 107 def post_install 108 {{ . }} 109 end 110 {{- end -}} 111 112 {{- with .Caveats }} 113 114 def caveats; <<~EOS 115 {{- range $index, $element := . }} 116 {{ . -}} 117 {{- end }} 118 EOS 119 end 120 {{- end -}} 121 122 {{- with .Plist }} 123 124 plist_options :startup => false 125 126 def plist; <<~EOS 127 {{ . }} 128 EOS 129 end 130 {{- end -}} 131 132 {{- if .Tests }} 133 134 test do 135 {{- range $index, $element := .Tests }} 136 {{ . -}} 137 {{- end }} 138 end 139 {{- end }} 140 end 141 `