Skip to content

feat: support addtional url parameters in homebrew cask #5800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sushichan044
Copy link
Contributor

@sushichan044 sushichan044 commented May 30, 2025

This change will enable users to generate Homebrew Cask definitions with additional parameters, documented as follows:
https://docs.brew.sh/Cask-Cookbook#additional-url-parameters

A specific use case is the ability to achieve automated releases with GoReleaser, even for Casks that require authentication for downloads or demand special cookies.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 30, 2025
Using string `yaml:"using,omitempty" json:"using,omitempty"`
Cookies map[string]string `yaml:"cookies,omitempty" json:"cookies,omitempty"`
Referer string `yaml:"referer,omitempty" json:"referer,omitempty"`
Headers []string `yaml:"headers,omitempty" json:"headers,omitempty"`
Copy link
Contributor Author

@sushichan044 sushichan044 May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the parameter actually required is header,
but in the Homebrew Formula config, it is written as headers. ref
So I also use headers here to reduce migration costs from Formula to Cask.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should write this note into code maybe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added: 949157e

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looking good so far!

Thank you!

@sushichan044
Copy link
Contributor Author

@caarlos0
We could also consider placing all additional parameters at the same level as url_template to enhance compatibility with Formula settings.

While this would reduce migration costs from Formula, I feel there are too many settings starting with url_.

I've implemented it by grouping the additional parameters for now, and I'd like your opinion on this.

@sushichan044 sushichan044 marked this pull request as ready for review May 31, 2025 13:59
@sushichan044
Copy link
Contributor Author

Ah I forgot to update docs.
I'll add it soon.

Copy link

codecov bot commented May 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.93%. Comparing base (15b4dd1) to head (d3bcc99).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5800   +/-   ##
=======================================
  Coverage   82.93%   82.93%           
=======================================
  Files         163      163           
  Lines       16297    16298    +1     
=======================================
+ Hits        13516    13517    +1     
  Misses       2190     2190           
  Partials      591      591           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sushichan044
Copy link
Contributor Author

sushichan044 commented Jun 1, 2025

@caarlos0
I have added docs.

While looking at the Cask documentation, I found that there are also additional parameters like these.
I will address these in a separate PR.
https://docs.brew.sh/Cask-Cookbook#subversion-urls
https://docs.brew.sh/Cask-Cookbook#git-urls

Comment on lines 68 to +78
url_template: "https://github.mycompany.com/foo/bar/releases/download/{{ .Tag }}/{{ .ArtifactName }}"

# Additional URL parameters for Homebrew Cask downloads.
# These parameters can be used to provide extra headers, cookies, or other
# download requirements for your application.
# See https://docs.brew.sh/Cask-Cookbook#additional-url-parameters for more details.
#
# All parameters are optional and will only be included in the generated cask
# if explicitly configured. No default values are set.
# Templates: allowed.
url_additional:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly a todo for me, butt maybe we can wrap this as all as:

url:
  template: "{{ ... }}"
  verified: ""
  using: ""
  # etc

wdyt? 🤔 if think this looks better I can do it in a subsequent PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly, consolidating the URL settings might be a good idea!

Copy link
Contributor Author

@sushichan044 sushichan044 Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caarlos0
However, if a significant number of users have configured url_template in Homebrew Forumula,
it would be advisable to prepare a Migration Guide (or some lighter docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interested in it anyway. 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caarlos0 caarlos0 enabled auto-merge (squash) June 2, 2025 11:57
@caarlos0 caarlos0 disabled auto-merge June 2, 2025 12:22
@caarlos0 caarlos0 merged commit c356f7d into goreleaser:main Jun 2, 2025
17 of 18 checks passed
@caarlos0
Copy link
Member

caarlos0 commented Jun 2, 2025

merged, thanks @sushichan044 🙏

caarlos0 added a commit that referenced this pull request Jun 2, 2025
one-shot this quickly so I don't forget about it 

refs
#5800 (comment)

closes #5797
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants