github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/www/docs/customization/homebrew.md (about) 1 --- 2 title: Homebrew 3 --- 4 5 After releasing to GitHub or GitLab, GoReleaser can generate and publish 6 a _homebrew-tap_ recipe into a repository that you have access to. 7 8 The `brews` section specifies how the formula should be created. 9 You can check the 10 [Homebrew documentation](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) 11 and the 12 [formula cookbook](https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md) 13 for more details. 14 15 !!! warning 16 If you have multiple 32-bit arm versions in each `build` section, and 17 you do not specify any `ids` in the brew section, it will default to all 18 artifacts and GoReleaser will fail. 19 20 ```yaml 21 # .goreleaser.yml 22 brews: 23 - 24 # Name template of the recipe 25 # Default to project name 26 name: myproject 27 28 # IDs of the archives to use. 29 # Defaults to all. 30 ids: 31 - foo 32 - bar 33 34 # GOARM to specify which 32-bit arm version to use if there are multiple versions 35 # from the build section. Brew formulas support atm only one 32-bit version. 36 # Default is 6 for all artifacts or each id if there a multiple versions. 37 goarm: 6 38 39 # NOTE: make sure the url_template, the token and given repo (github or gitlab) owner and name are from the 40 # same kind. We will probably unify this in the next major version like it is done with scoop. 41 42 # GitHub/GitLab repository to push the formula to 43 # Gitea is not supported yet, but the support coming 44 tap: 45 owner: repo-owner 46 name: homebrew-tap 47 # Optionally a token can be provided, if it differs from the token provided to GoReleaser 48 token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" 49 50 # Template for the url which is determined by the given Token (github or gitlab) 51 # Default for github is "https://github.com/<repo_owner>/<repo_name>/releases/download/{{ .Tag }}/{{ .ArtifactName }}" 52 # Default for gitlab is "https://gitlab.com/<repo_owner>/<repo_name>/-/releases/{{ .Tag }}/downloads/{{ .ArtifactName }}" 53 # Default for gitea is "https://gitea.com/<repo_owner>/<repo_name>/releases/download/{{ .Tag }}/{{ .ArtifactName }}" 54 url_template: "http://github.mycompany.com/foo/bar/releases/{{ .Tag }}/{{ .ArtifactName }}" 55 56 # Allows you to set a custom download strategy. Note that you'll need 57 # to implement the strategy and add it to your tap repository. 58 # Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly 59 # Default is empty. 60 download_strategy: CurlDownloadStrategy 61 62 # Allows you to add a custom require_relative at the top of the formula template 63 # Default is empty 64 custom_require: custom_download_strategy 65 66 # Git author used to commit to the repository. 67 # Defaults are shown. 68 commit_author: 69 name: goreleaserbot 70 email: goreleaser@carlosbecker.com 71 72 # The project name and current git tag are used in the format string. 73 commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" 74 75 # Folder inside the repository to put the formula. 76 # Default is the root folder. 77 folder: Formula 78 79 # Caveats for the user of your binary. 80 # Default is empty. 81 caveats: "How to use this binary" 82 83 # Your app's homepage. 84 # Default is empty. 85 homepage: "https://example.com/" 86 87 # Template of your app's description. 88 # Default is empty. 89 description: "Software to create fast and easy drum rolls." 90 91 # SPDX identifier of your app's license. 92 # Default is empty. 93 license: "MIT" 94 95 # Setting this will prevent goreleaser to actually try to commit the updated 96 # formula - instead, the formula file will be stored on the dist folder only, 97 # leaving the responsibility of publishing it to the user. 98 # If set to auto, the release will not be uploaded to the homebrew tap 99 # in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1 100 # Default is false. 101 skip_upload: true 102 103 # Custom block for brew. 104 # Can be used to specify alternate downloads for devel or head releases. 105 # Default is empty. 106 custom_block: | 107 head "https://github.com/some/package.git" 108 ... 109 110 # Packages your package depends on. 111 dependencies: 112 - name: git 113 - name: zsh 114 type: optional 115 116 # Packages that conflict with your package. 117 conflicts: 118 - svn 119 - bash 120 121 # Specify for packages that run as a service. 122 # Default is empty. 123 plist: | 124 <?xml version="1.0" encoding="UTF-8"?> 125 ... 126 127 # So you can `brew test` your formula. 128 # Default is empty. 129 test: | 130 system "#{bin}/program --version" 131 ... 132 133 # Custom install script for brew. 134 # Default is 'bin.install "program"'. 135 install: | 136 bin.install "program" 137 ... 138 139 # Custom post_install script for brew. 140 # Could be used to do any additional work after the "install" script 141 # Default is empty. 142 post_install: | 143 etc.install "app-config.conf" 144 ... 145 ``` 146 147 !!! tip 148 Learn more about the [name template engine](/customization/templates/). 149 150 By defining the `brew` section, GoReleaser will take care of publishing the 151 Homebrew tap. 152 Assuming that the current tag is `v1.2.3`, the above configuration will generate a 153 `program.rb` formula in the `Formula` folder of `user/homebrew-tap` repository: 154 155 ```rb 156 class Program < Formula 157 desc "How to use this binary" 158 homepage "https://github.com/user/repo" 159 version "v1.2.3" 160 161 if os.Mac? 162 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_macOs_64bit.zip" 163 sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74" 164 end 165 if OS.linux? && Hardware::CPU.intel? 166 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_64bit.zip" 167 sha256 "b41bebd25fd7bb1a67dc2cd5ee12c9f67073094567fdf7b3871f05fd74a45fdd" 168 end 169 if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? 170 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_armv7.zip" 171 sha256 "78f31239430eaaec01df783e2a3443753a8126c325292ed8ddb1658ddd2b401d" 172 end 173 if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit? 174 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_arm64.zip" 175 sha256 "97cadca3c3c3f36388a4a601acf878dd356d6275a976bee516798b72bfdbeecf" 176 end 177 178 depends_on "git" 179 depends_on "zsh" => :optional 180 181 def install 182 bin.install "program" 183 end 184 185 def post_install 186 etc.install "app-config.conf" 187 end 188 end 189 ``` 190 191 !!! info 192 Note that GoReleaser does not generate a valid homebrew-core formula. 193 The generated formulas are meant to be published as 194 [homebrew taps](https://docs.brew.sh/Taps.html), and in their current 195 form will not be accepted in any of the official homebrew repositories. 196 197 ## Head Formulas 198 199 GoReleaser does not generate `head` formulas for you, as it may be very different 200 from one software to another. 201 202 Our suggestion is to create a `my-app-head.rb` file on your tap following 203 [homebrew's documentation](https://docs.brew.sh/Formula-Cookbook#unstable-versions-head).