Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
New feature: Allow download from private GitHub repository #1763
I would like to download the release asset of the private GitHub repository.
I'm using a private brew tap at my company and the prebuild binaries for internal tools are uploaded to the private GitHub Release page.
What I did
I implemented a new DownloadStrategy to find and download asset using GitHub API.
How I did it
First, resolve the asset_id associated with the release tag with the following API:
and then, download the asset with the following API:
How to verify it
To use it, add
require "formula" class Hoge < Formula url "https://github.com/:owner/:repo/releases/download/:tag/hoge_v0.1.0_darwin_amd64.tar.gz", :using => GitHubReleaseDownloadStrategy ... end
$ export HOMEBREW_GITHUB_API_TOKEN=xxxxxx $ brew install hoge
Please review this.
@minamijoyo I'm thinking this download strategy could be a lot more general and instead be e.g.
@MikeMcQuaid Thanks for review and advice.
Certainly the archive url can be accessed with the curl.
But the releases url is not. In the case of the a private repository, even if you set a token, not found is returned. I don't know why there is such a difference. Try it with a private repository.
Although the url of assets API can be accessed with the curl, asset_id is not shown on Web, I don't know how to get asset_id without API.
In addition, to download the asset's binary content, we must set the Accept header of the request to
Therefore it is difficult to make it a common implementation without API calls. Is there a way to go something good? If we assume that both logic are implemented respectively, I think that it is better to separate them into different classes, but one is not what I originally wanted to do.
@minamijoyo I think it's fine to have API calls if they are needed for releases
It may be worth asking firstname.lastname@example.org why this is the case and their thoughts; they will definitely be able to help.
I contacted GitHub's support and got answers. The summary is as follows:
After all, we can not get the private release assets without API.