It would be great if Homebrew Cask was able to install from private GitHub Releases. As far as I can tell, this is not possible right now without hacks because custom headers are not supported within the url stanza and GitHub's API requires the Accept: application/octet-stream header to download a binary.
Homebrew Cask can download from pretty much every other source and offers many options to customize the download including support for POST, cookies, referer, and user agent strings. What it doesn't seem to offer is support for custom headers, which is exactly what is needed to get GitHub's API to correctly respond with the binary for a specific release.
I was able to hack a solution in by using the [url stanza block syntax][]:
url do
require 'open-uri'
download_uri = URI::HTTPS.build(
host: 'api.github.com',
path: '/repos/my-organization/my-private-repo/releases/assets/1234567',
query: URI.encode_www_form(
'access_token' => 'MACHINE_USER_ACCESS_TOKEN'
)
)
download_path = download_uri.open('Accept' => 'application/octet-stream').path
URI.join('file:', download_path).to_s
end
However, I'm not happy with this solution because
I would be more than willing to implement the code to make this feature a reality. I see two potential solutions:
headers key to additional HTTP/S URL parameters and implementing custom headers in CurlDownloadStrategy. This would make using private GitHub releases possible but somewhat complex. It's also a more general solution.GitHubPrivateRepositoryDownloadStrategy which could be adapted for this purpose. This would make use of private GitHub releases dead simple.I am looking for some guidance on which solution is more desirable.
My company has a private GitHub organization that we use for collaboration. We are investigating and hope to use Homebrew Cask for distributing some internal tooling. GitHub already provides all the necessary features to develop and maintain an internal tool, so private GitHub Releases are a natural fit for making the tool available within our company. It would be great for us and most likely other organizations if Homebrew Cask facilitated this workflow!
Thank you for reading and for maintaining Homebrew Cask! :smile:
Since you’re willing to do the legwork, I don’t oppose this. If HB already has a strategy that could be adapted and make implementation easier, then I’m for that solution.
That said, @reitermarkus will probably be the one to review your PR and maintain your code, so I’d like to get his thoughts first.
As long as it reuses the already existing download strategy, this should be fine. Ideally, both Formulae and Casks should use the same strategy, so it would be great if you could look into making the same base strategy work for both.
@reitermarkus Ok, thanks, I will do that! Going to try to start looking at this next week.
@seanfisk Are you still interested in implementing this? If not we'll close the issue.
@commitay Yes, I am. I'm under quite a bit of pressure at work to finish other stuff, so I can't promise when I'll get to it. If you want to close it for now, that's fine — I can re-open when I'm able to implement. Either way is good for me! Thanks for following up 👍
Thanks, @seanfisk, closing this for now in favour of a future PR.
Most helpful comment
Thanks, @seanfisk, closing this for now in favour of a future PR.