github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/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>/uploads/{{ .ArtifactUploadHash }}/{{ .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 # Folder inside the repository to put the formula. 73 # Default is the root folder. 74 folder: Formula 75 76 # Caveats for the user of your binary. 77 # Default is empty. 78 caveats: "How to use this binary" 79 80 # Your app's homepage. 81 # Default is empty. 82 homepage: "https://example.com/" 83 84 # Your app's description. 85 # Default is empty. 86 description: "Software to create fast and easy drum rolls." 87 88 # SPDX identifier of your app's license. 89 # Default is empty. 90 license: "MIT" 91 92 # Setting this will prevent goreleaser to actually try to commit the updated 93 # formula - instead, the formula file will be stored on the dist folder only, 94 # leaving the responsibility of publishing it to the user. 95 # If set to auto, the release will not be uploaded to the homebrew tap 96 # in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1 97 # Default is false. 98 skip_upload: true 99 100 # Custom block for brew. 101 # Can be used to specify alternate downloads for devel or head releases. 102 # Default is empty. 103 custom_block: | 104 head "https://github.com/some/package.git" 105 ... 106 107 # Packages your package depends on. 108 dependencies: 109 - name: git 110 - name: zsh 111 type: optional 112 113 # Packages that conflict with your package. 114 conflicts: 115 - svn 116 - bash 117 118 # Specify for packages that run as a service. 119 # Default is empty. 120 plist: | 121 <?xml version="1.0" encoding="UTF-8"?> 122 ... 123 124 # So you can `brew test` your formula. 125 # Default is empty. 126 test: | 127 system "#{bin}/program --version" 128 ... 129 130 # Custom install script for brew. 131 # Default is 'bin.install "program"'. 132 install: | 133 bin.install "program" 134 ... 135 ``` 136 137 !!! tip 138 Learn more about the [name template engine](/customization/templates/). 139 140 By defining the `brew` section, GoReleaser will take care of publishing the 141 Homebrew tap. 142 Assuming that the current tag is `v1.2.3`, the above configuration will generate a 143 `program.rb` formula in the `Formula` folder of `user/homebrew-tap` repository: 144 145 ```rb 146 class Program < Formula 147 desc "How to use this binary" 148 homepage "https://github.com/user/repo" 149 version "v1.2.3" 150 151 if os.Mac? 152 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_macOs_64bit.zip" 153 sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74" 154 end 155 if OS.linux? && Hardware::CPU.intel? 156 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_64bit.zip" 157 sha256 "b41bebd25fd7bb1a67dc2cd5ee12c9f67073094567fdf7b3871f05fd74a45fdd" 158 end 159 if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? 160 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_armv7.zip" 161 sha256 "78f31239430eaaec01df783e2a3443753a8126c325292ed8ddb1658ddd2b401d" 162 end 163 if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit? 164 url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_arm64.zip" 165 sha256 "97cadca3c3c3f36388a4a601acf878dd356d6275a976bee516798b72bfdbeecf" 166 end 167 168 depends_on "git" 169 depends_on "zsh" => :optional 170 171 def install 172 bin.install "program" 173 end 174 end 175 ``` 176 177 !!! info 178 Note that GoReleaser does not generate a valid homebrew-core formula. 179 The generated formulas are meant to be published as 180 [homebrew taps](https://docs.brew.sh/Taps.html), and in their current 181 form will not be accepted in any of the official homebrew repositories. 182 183 ## Head Formulas 184 185 GoReleaser does not generate `head` formulas for you, as it may be very different 186 from one software to another. 187 188 Our suggestion is to create a `my-app-head.rb` file on your tap following 189 [homebrew's documentation](https://docs.brew.sh/Formula-Cookbook#unstable-versions-head).