github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/homebrew.md (about)

     1  # Homebrew Taps
     2  
     3  After releasing to GitHub, GitLab, or Gitea, GoReleaser can generate and publish
     4  a _homebrew-tap_ recipe into a repository that you have access to.
     5  
     6  The `brews` section specifies how the formula should be created.
     7  You can check the
     8  [Homebrew documentation](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md),
     9  and the
    10  [formula cookbook](https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md)
    11  for more details.
    12  
    13  ```yaml
    14  # .goreleaser.yaml
    15  brews:
    16    -
    17      # Name of the recipe
    18      #
    19      # Default: ProjectName
    20      # Templates: allowed
    21      name: myproject
    22  
    23      # Alternative names for the current recipe.
    24      #
    25      # Useful if you want to publish a versioned formula as well, so users can
    26      # more easily downgrade.
    27      #
    28      # Since: v1.20 (pro)
    29      # Templates: allowed
    30      alternative_names:
    31        - myproject@{{ .Version }}
    32        - myproject@{{ .Major }}
    33  
    34      # IDs of the archives to use.
    35      # Empty means all IDs.
    36      ids:
    37      - foo
    38      - bar
    39  
    40      # Sets the app file within a DMG.
    41      #
    42      # Since: 1.24 (pro)
    43      app: MyApp.app
    44  
    45      # GOARM to specify which 32-bit arm version to use if there are multiple
    46      # versions from the build section. Brew formulas support only one 32-bit
    47      # version.
    48      #
    49      # Default: 6
    50      goarm: 6
    51  
    52      # GOAMD64 to specify which amd64 version to use if there are multiple
    53      # versions from the build section.
    54      #
    55      # Default: v1
    56      goamd64: v1
    57  
    58      # NOTE: make sure the url_template, the token and given repo (github or
    59      # gitlab) owner and name are from the same kind.
    60      # We will probably unify this in the next major version like it is
    61      # done with scoop.
    62  
    63      # URL which is determined by the given Token (github, gitlab or gitea).
    64      #
    65      # Default depends on the client.
    66      # Templates: allowed
    67      url_template: "https://github.mycompany.com/foo/bar/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
    68  
    69      # Headers to include in the `url` stanza.
    70      # This can be a more modern alternative to `download_strategy` in some
    71      # cases.
    72      #
    73      # Since: v1.25
    74      url_headers:
    75        - "Accept: application/octet-stream"
    76        - 'Authorization: bearer #{ENV["HOMEBREW_GITHUB_API_TOKEN"]}'
    77  
    78      # Allows you to set a custom download strategy. Note that you'll need
    79      # to implement the strategy and add it to your tap repository.
    80      # Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly
    81      download_strategy: CurlDownloadStrategy
    82  
    83      # Allows you to add a custom require_relative at the top of the formula
    84      # template.
    85      custom_require: custom_download_strategy
    86  
    87      # Git author used to commit to the repository.
    88      commit_author:
    89        name: goreleaserbot
    90        email: bot@goreleaser.com
    91  
    92      # The project name and current git tag are used in the format string.
    93      #
    94      # Templates: allowed
    95      commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
    96  
    97      # Directory inside the repository to put the formula.
    98      directory: Formula
    99  
   100      # Caveats for the user of your binary.
   101      caveats: "How to use this binary"
   102  
   103      # Your app's homepage.
   104      homepage: "https://example.com/"
   105  
   106      # Your app's description.
   107      #
   108      # Templates: allowed
   109      description: "Software to create fast and easy drum rolls."
   110  
   111      # SPDX identifier of your app's license.
   112      license: "MIT"
   113  
   114      # Setting this will prevent goreleaser to actually try to commit the updated
   115      # formula - instead, the formula file will be stored on the dist directory
   116      # only, leaving the responsibility of publishing it to the user.
   117      # If set to auto, the release will not be uploaded to the homebrew tap
   118      # in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
   119      #
   120      # Templates: allowed
   121      skip_upload: true
   122  
   123      # Custom block for brew.
   124      # Can be used to specify alternate downloads for devel or head releases.
   125      custom_block: |
   126        head "https://github.com/some/package.git"
   127        ...
   128  
   129      # Packages your package depends on.
   130      dependencies:
   131        - name: git
   132          # Allow to specify the OS in which the dependency is required.
   133          # Valid options are `mac` and `linux`.
   134          #
   135          # Since: v1.23.0
   136          os: mac
   137        - name: zsh
   138          type: optional
   139        - name: fish
   140          version: v1.2.3
   141        # if providing both version and type, only the type will be taken into
   142        # account.
   143        - name: elvish
   144          type: optional
   145          version: v1.2.3
   146  
   147  
   148      # Packages that conflict with your package.
   149      conflicts:
   150        - svn
   151        - bash
   152  
   153      # Specify for packages that run as a service.
   154      plist: |
   155        <?xml version="1.0" encoding="UTF-8"?>
   156        # ...
   157  
   158      # Service block.
   159      #
   160      # Since: v1.7
   161      service: |
   162        run: foo/bar
   163        # ...
   164  
   165      # So you can `brew test` your formula.
   166      #
   167      # Template: allowed
   168      test: |
   169        system "#{bin}/foo --version"
   170        # ...
   171  
   172      # Custom install script for brew.
   173      #
   174      # Template: allowed
   175      # Default: 'bin.install "BinaryName"'
   176      install: |
   177        bin.install "some_other_name"
   178        bash_completion.install "completions/foo.bash" => "foo"
   179        # ...
   180  
   181      # Additional install instructions so you don't need to override `install`.
   182      #
   183      # Template: allowed
   184      # Since: v1.20
   185      extra_install: |
   186        bash_completion.install "completions/foo.bash" => "foo"
   187        man1.install "man/foo.1.gz"
   188        # ...
   189  
   190      # Custom post_install script for brew.
   191      # Could be used to do any additional work after the "install" script
   192      post_install: |
   193      	etc.install "app-config.conf"
   194        # ...
   195  
   196  {% include-markdown "../includes/repository.md" comments=false %}
   197  ```
   198  
   199  !!! tip
   200  
   201      Learn more about the [name template engine](/customization/templates/).
   202  
   203  By defining the `brew` section, GoReleaser will take care of publishing the
   204  Homebrew tap.
   205  Assuming that the current tag is `v1.2.3`, the above configuration will generate a
   206  `program.rb` formula in the `Formula` directory of `user/homebrew-tap`
   207  repository:
   208  
   209  ```rb
   210  class Program < Formula
   211    desc "How to use this binary"
   212    homepage "https://github.com/user/repo"
   213    version "v1.2.3"
   214  
   215    on_macos do
   216      url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_macOs_64bit.zip"
   217      sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74"
   218    end
   219  
   220    on_linux
   221      if Hardware::CPU.intel?
   222        url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_64bit.zip"
   223        sha256 "b41bebd25fd7bb1a67dc2cd5ee12c9f67073094567fdf7b3871f05fd74a45fdd"
   224      end
   225      if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
   226        url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_armv7.zip"
   227        sha256 "78f31239430eaaec01df783e2a3443753a8126c325292ed8ddb1658ddd2b401d"
   228      end
   229      if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
   230        url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_arm64.zip"
   231        sha256 "97cadca3c3c3f36388a4a601acf878dd356d6275a976bee516798b72bfdbeecf"
   232      end
   233    end
   234  
   235    depends_on "git"
   236    depends_on "zsh" => :optional
   237  
   238    def install
   239      bin.install "program"
   240    end
   241  
   242    def post_install
   243    	etc.install "app-config.conf"
   244    end
   245  end
   246  ```
   247  
   248  !!! info
   249  
   250      Note that GoReleaser does not generate a valid homebrew-core formula.
   251      The generated formulas are meant to be published as
   252      [homebrew taps](https://docs.brew.sh/Taps.html), and in their current
   253      form will not be accepted in any of the official homebrew repositories.
   254  
   255  ## Head Formulas
   256  
   257  GoReleaser does not generate `head` formulas for you, as it may be very different
   258  from one software to another.
   259  
   260  Our suggestion is to create a `my-app-head.rb` file on your tap following
   261  [homebrew's documentation](https://docs.brew.sh/Formula-Cookbook#unstable-versions-head).
   262  
   263  ## Versioned formulas
   264  
   265  !!! success "GoReleaser Pro"
   266  
   267      This requires [GoReleaser Pro](/pro/).
   268  
   269  GoReleaser can also create a versioned formula.
   270  For instance, you might want to make keep previous minor versions available to
   271  your users, so they easily downgrade and/or keep using an older version.
   272  
   273  To do that, use `alternative_names`:
   274  
   275  ```yaml
   276  # .goreleaser.yaml
   277  brews:
   278    - name: foo
   279      alternative_names:
   280        - "foo@{{ .Major }}.{{ .Minor }}"
   281      # other fields
   282  ```
   283  
   284  So, if you tag `v1.2.3`, GoReleaser will create and push `foo.rb` and
   285  `foo@1.2.rb`.
   286  
   287  Later on, you can tag `v1.3.0`, and then GoReleaser will create and push both
   288  `foo.rb` (thus overriding the previous version) and `foo@1.3.rb`.
   289  Your users can then `brew install foo@1.2` to keep using the previous version.
   290  
   291  ## GitHub Actions
   292  
   293  To publish a formula from one repository to another using GitHub Actions, you cannot use the default action token.
   294  You must use a separate token with content write privileges for the tap repository.
   295  You can check the [resource not accessible by integration](https://goreleaser.com/errors/resource-not-accessible-by-integration/) for more information.
   296  
   297  ## Limitations
   298  
   299  - Only one `GOARM` build is allowed;
   300  
   301  {% include-markdown "../includes/prs.md" comments=false %}