Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Add support for private repos using env var or netrc #78

Closed
wants to merge 1 commit into from

Conversation

codyaray
Copy link

@codyaray codyaray commented Jun 7, 2018

This adds support for using goreleaser against a private github repo. It authenticates using a personal access token. This token must have repo permissions to read the private repo. Note: this works for 2FA enabled as well.

It checks for either a GITHUB_TOKEN env var or the api.github.com machine in your ~/.netrc file. This supports the token in both the password or the login field of the github machine.

For example, both of these will work:

machine api.github.com
        login codyaray
        password xxxxxxxxxxxxxxxxxxxxxxxxxxx
machine api.github.com login xxxxxxxxxxxxxxxxxxxxxxxxxxx

I also updated the goreleaser version so godownloader supports gcflags, asmflags, and similar configuration.

Now you can do something like this:

curl -ns https://api.github.com/repos/YOU/YOURAPP/contents/godownloader.sh?ref=master -H Accept:application/vnd.github.raw | bash

You're still able to shorten the URL but the header is required. So you might just wrap that in another bash script just to add the header. Create a public gist with the following contents:

curl -ns https://api.github.com/repos/YOU/YOURAPP/contents/godownloader.sh?ref=master -H Accept:application/vnd.github.raw | bash -s -- $@

Now create a short URL pointing to your public gist. Your users still get a nice short one-liner like

curl -ns https://git.io/yourapp | bash

Fixes #69

@codyaray codyaray force-pushed the private-repo branch 2 times, most recently from 126e301 to c8b3a23 Compare June 7, 2018 04:05
@codyaray
Copy link
Author

codyaray commented Jun 7, 2018

The test is failing because the API is rate limited unless you authenticate, and there's a lot of tests running in quick succession. So it might be useful to authenticate on CI for this reason.

You're allowed 60 requests per hour unauthenticated (per IP address) and 5000 requests per hour authenticated.

codyaray added a commit to confluentinc/cli that referenced this pull request Jun 7, 2018
Since our cli repo is still private, I had to use a forked `godownloader`.
PR to merge back upstream: goreleaser/godownloader#78
@caarlos0
Copy link
Member

caarlos0 commented Jun 7, 2018

I'll take a look at this later today.

@@ -25,6 +25,49 @@
]
revision = "ff0f66940b829dc66c81dad34746d4349b83eb9e"

[[projects]]
name = "github.com/aws/aws-sdk-go"
Copy link
Member

Choose a reason for hiding this comment

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

this change seems unrelated...

@@ -205,10 +204,11 @@ adjust_arch
log_info "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}"

{{ .Archive.NameTemplate }}
GITHUB_DOWNLOAD=https://api.github.com/repos/${OWNER}/${REPO}/releases/tags/${TAG}
Copy link
Member

Choose a reason for hiding this comment

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

this will hit rate limits on travis & cia...

@caarlos0
Copy link
Member

caarlos0 commented Jun 8, 2018

I'm not sure... we were not using the API on purpose to avoid rate limit errors on OSS projects...

maybe @client9 can give a better opinion...

@codyaray
Copy link
Author

codyaray commented Jun 9, 2018

Yeah, that's my main concern as well. I don't think there's a way to support private repos without hitting the API endpoints though.

@github-actions
Copy link

github-actions bot commented Oct 5, 2019

Stale pull request message

@sysbot
Copy link

sysbot commented Nov 12, 2019

@caarlos0 @codyaray anything I can help with to get this moving and possibly merge? I'm also interested in this.

@polothy
Copy link

polothy commented Nov 14, 2019

Would a flag be helpful?

  • If no --private it uses current pattern that avoids API limits and generates the same install.sh as before.
  • With --private it assumes you have a token and API limits are no longer a problem and we can use APIs, etc. It would generate an install.sh that requires a token.

@caarlos0
Copy link
Member

@polothy I think that makes sense...

@codyaray
Copy link
Author

codyaray commented Dec 18, 2019

@caarlos0 so can we do this? Can you wrap this up with the --private flag if you're ok with it.

We'd still need this to fully do the homebrew with a private github repo, even if we have goreleaser/goreleaser#507, right?

(I noticed that #69 was closed. 😢 )

@caarlos0
Copy link
Member

Please see #161

@github-actions
Copy link

This pull-request seems be stale, will auto-close soon.

@github-actions github-actions bot added the stale label Feb 18, 2020
@github-actions github-actions bot closed this Feb 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Private github repository
4 participants