[Homebrew Cask] Support dynamic construction of download URLs #5817
Replies: 3 comments 11 replies
-
Interesting. Should we maybe incorporate a version of that into goreleaser, and allow the users to do something like: homebrew_casks:
- private: true wdyt? |
Beta Was this translation helpful? Give feedback.
-
@caarlos0 I think it's better to limit support to dynamic URL assembly with the |
Beta Was this translation helpful? Give feedback.
-
I'm trying to install a Cask with the suggested
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Related discussions:
Following up on our previous discussions, I am currently working on migrating our internal formulas to Casks.
Current Private Formula Setup
I originally used a custom download strategy for our Formulas to distribute them privately via the GitHub API.
This was configurable in GoReleaser using
download_strategy
andcustom_require
.Problem Encountered During Migration to a Private Cask
To distribute a Cask in the same way, I need to build the URL dynamically, as shown in the example below.
https://github.com/sushichan044/homebrew-experimental-tap/blob/d0351ea9ab480fc56b7038898b7bd49eedbc591f/Casks/example-go-cask.rb#L13-L34
This is the approach introduced in the Cask Cookbook as "Arbitrary Ruby methods".
https://docs.brew.sh/Cask-Cookbook#arbitrary-ruby-methods
Currently, this cannot be done with GoReleaser.
This is because the Ruby code set in
custom_block
is placed below the OS-specific URL settings.As a result, the Custom Module is out of scope and inaccessible at the time the URL is constructed.
Proposed Changes
Option 1
One option is to place the Ruby block set by
custom_block
as high up as possible. For example, it could be placed between thelivecheck
andbinary
stanzas.This makes the Ruby module defined in
custom_block
accessible when the URL is constructed.goreleaser/internal/pipe/cask/templates/cask.rb
Lines 7 to 13 in 99b7f9c
Option 2 ( Alternative )
Alternatively, it is also possible to use a block to dynamically construct the URL in a Homebrew Cask, as shown below.
https://docs.brew.sh/Cask-Cookbook#writing-the-block
I tried this implementation pattern locally, but the URL DSL was so expressive that it seemed extremely difficult to map into the Go Template.
This block pattern is required to detect the download URL from the page's HTML dynamically, but it seems we don't need to support this feature unless there is strong demand for it.
Beta Was this translation helpful? Give feedback.
All reactions