github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/internal/pipe/brew/template.go (about) 1 package brew 2 3 import "github.com/goreleaser/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 = `# typed: false 33 # frozen_string_literal: true 34 35 # This file was generated by GoReleaser. DO NOT EDIT. 36 {{ if .CustomRequire -}} 37 require_relative "{{ .CustomRequire }}" 38 {{ end -}} 39 class {{ .Name }} < Formula 40 desc "{{ .Desc }}" 41 homepage "{{ .Homepage }}" 42 version "{{ .Version }}" 43 {{ if .License -}} 44 license "{{ .License }}" 45 {{ end -}} 46 bottle :unneeded 47 {{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }} 48 depends_on :linux 49 {{- end }} 50 {{- printf "\n" }} 51 {{- if .MacOS.DownloadURL }} 52 if OS.mac? 53 url "{{ .MacOS.DownloadURL }}" 54 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 55 sha256 "{{ .MacOS.SHA256 }}" 56 end 57 {{- end }} 58 59 {{- if .LinuxAmd64.DownloadURL }} 60 if OS.linux? && Hardware::CPU.intel? 61 url "{{ .LinuxAmd64.DownloadURL }}" 62 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 63 sha256 "{{ .LinuxAmd64.SHA256 }}" 64 end 65 {{- end }} 66 67 {{- if .LinuxArm.DownloadURL }} 68 if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? 69 url "{{ .LinuxArm.DownloadURL }}" 70 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 71 sha256 "{{ .LinuxArm.SHA256 }}" 72 end 73 {{- end }} 74 75 {{- if .LinuxArm64.DownloadURL }} 76 if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit? 77 url "{{ .LinuxArm64.DownloadURL }}" 78 {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }} 79 sha256 "{{ .LinuxArm64.SHA256 }}" 80 end 81 {{- end }} 82 83 {{- with .CustomBlock }} 84 {{ range $index, $element := . }} 85 {{ . }} 86 {{- end }} 87 {{- end }} 88 89 {{- with .Dependencies }} 90 {{ range $index, $element := . }} 91 depends_on "{{ .Name }}" 92 {{- if .Type }} => :{{ .Type }}{{- end }} 93 {{- end }} 94 {{- end -}} 95 96 {{- with .Conflicts }} 97 {{ range $index, $element := . }} 98 conflicts_with "{{ . }}" 99 {{- end }} 100 {{- end }} 101 102 def install 103 {{- range $index, $element := .Install }} 104 {{ . -}} 105 {{- end }} 106 end 107 108 {{- with .PostInstall }} 109 110 def post_install 111 {{ . }} 112 end 113 {{- end -}} 114 115 {{- with .Caveats }} 116 117 def caveats; <<~EOS 118 {{- range $index, $element := . }} 119 {{ . -}} 120 {{- end }} 121 EOS 122 end 123 {{- end -}} 124 125 {{- with .Plist }} 126 127 plist_options :startup => false 128 129 def plist; <<~EOS 130 {{ . }} 131 EOS 132 end 133 {{- end -}} 134 135 {{- if .Tests }} 136 137 test do 138 {{- range $index, $element := .Tests }} 139 {{ . -}} 140 {{- end }} 141 end 142 {{- end }} 143 end 144 `