Skip to content
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

Support for Homebrew Cask #42

Open
MWin123 opened this issue Dec 7, 2022 · 7 comments
Open

Support for Homebrew Cask #42

MWin123 opened this issue Dec 7, 2022 · 7 comments

Comments

@MWin123
Copy link

MWin123 commented Dec 7, 2022

Hi,

are there any plans to add support for Homebrew casks?

According to How to Open a Homebrew Pull Request there is a cask version of brew bump-formula-pr as well, i.e., brew bump-cask-pr.

@mislav
Copy link
Owner

mislav commented Dec 7, 2022

Hi, I don't have experience with updating casks. I'm not opposed to the feature.

What fields do you typically need updated when bumping a cask formula?

@MWin123
Copy link
Author

MWin123 commented Dec 13, 2022

Great! It seems like currently there is no working GitHub Action to update casks.

I don't have that much experience with Homebrew formulas or casks, but I believe that version, sha256 (generated) & url are the most important fields to update.

In my cask repo we just update version & sha256 because the url contains #{version}.

@mislav
Copy link
Owner

mislav commented Dec 14, 2022

@MWin123 This Action should already have the ability to update those fields in a file in theory. You can also use the formula-path input parameter to override the file path to be edited to something like Casks/mycask.rb. Could you try that?

const filePath = getInput('formula-path') || `Formula/${formulaName}.rb`

@MWin123
Copy link
Author

MWin123 commented Jan 31, 2023

Thanks, I just tested the action with formula-path: Casks/mycask.rb, and it worked! It created a PR for the cask with an updated version, sha256 & url.

Unfortunately, there was one problem. brew audit fails now.

brew audit --tap=mwin123/esque
==> FAILED
Full audit --tap=mwin123/esque output
  audit for kafkaesque: failed
   - Use `sha256 :no_check` when URL is unversioned.
  Error: 1 problem in 1 cask detected
  Error: Use `sha256 :no_check` when URL is unversioned.

Currently, it uses the following url in the cask definition where the url references the version field.

version "2.4.0"
sha256 "..."
url "https://github.com/patschuh/KafkaEsque/releases/download/v#{version}/kafkaesque-#{version}.dmg"

This solution passes brew audit, so it seems like it would be best to keep the current, "versioned" url.

Is it possible to just update the version and sha256 fields, and leave the url field unchanged? If I change the url in the action to the one in the cask definition, the download fails, and it can't generate the hash.

Sorry my late reply.

Edit: I forked this repo, and commented out the following line.

replacements.set('url', downloadUrl)

With the forked action it works as expected. It doesn't replace the url field, and brew audit is successful.

If you decided to add explicit support for Homebrew casks, a feature toggle could be used to disable the url replacement for casks.

@mislav
Copy link
Owner

mislav commented Jan 31, 2023

@MWin123 Thanks for the deep dive into this and for sharing your solution.

I think you could set addition parameters to get around your problem:

formula-path: Casks/mycask.rb
download-url: https://github.com/patschuh/KafkaEsque/releases/download/v#{version}/kafkaesque-#{version}.dmg
download-sha256: <CHECKSUM>

assuming that the #{...} syntax will not be expanded by either GitHub Actions nor YAML processing, when "CHECKSUM" value is the sha256 of the .dmg file being released, it should all come together and work for your case in theory.

If embedding #{version} in download URLs for Homebrew is commonpractice, I could consider a change to support that interpolation in this action. By having that feature, the download-sha256 param would again become optional as it can be calculated on the fly.

@MWin123
Copy link
Author

MWin123 commented Jan 31, 2023

I'm not sure if I'm missing something but where would I get the checksum from?

If embedding #{version} in download URLs for Homebrew is commonpractice

I randomly clicked on a few casks in the official cask repo, and they all had a version parameter in the URL. If brew audit fails otherwise, it's probably mandatory for official casks.

@p-linnane
Copy link

I sometimes see this action when I'm merging cask PR's:
https://github.com/macauley/action-homebrew-bump-cask

Might be good for inspiration 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants