wangyoucao577 / go-release-action

Automatically publish Go binaries to Github Release Assets through Github Action.
https://github.com/marketplace/actions/go-release-binaries
MIT License
474 stars 74 forks source link

Support for self-hosted enterprise github #165

Open david1155 opened 3 months ago

david1155 commented 3 months ago

Hi,

It may be good to add support for GitHub Enterprise:

+ github-assets-uploader -logtostderr -f ../zi-tfc-env0-v0.1.0-linux-arm64.tar.gz -mediatype application/gzip -repo Terraform/env0-migration-go -token *** -tag=v0.1.0 -releasename= -retry 3
W0322 20:18:09.198415    1513 main.go:48] Upload asset error, will retry in 11s: GET https://api.github.com/repos/Enterprise/company-repo/releases/tags/v0.1.0: 401 Bad credentials []
wangyoucao577 commented 3 months ago

The upload tool has supported it already, see
https://github.com/wangyoucao577/assets-uploader/blob/a3e2d69c04c739d533cac3f583f564860622a2cd/cmd/github-assets-uploader/main.go#L68

You may need to set a baseurl flag for it, which hasn't been exposed on the action. I'm not able to test with Github Enterprise, so would you please fork the action to have a try? Add your baseurl https://github.com/wangyoucao577/go-release-action/blob/e48e16c995dd667d496ab7a18f83942a21c3d766/release.sh#L195 here.

PR is welcome if it works. We may need to add an extra enterprise_url option for this, or maybe there'll be the URL env during action runnning? In such case, we could fetch it from env and no need for option anymore.

bigjew92 commented 3 months ago

Looking for this as well. Looks like GITHUB_API_URL and GITHUB_SERVER_URL get exposed to the job, so might not need to add an extra option. Checked here: https://docs.github.com/en/actions/learn-github-actions/variables and also on the output from one of our runners jobs where this was failing.

GITHUB_SERVER_URL=https://git.mycompany.com/ GITHUB_API_URL=https://git.mycompany.com/api/v3

Tested with an internal repository to my enterprise instance. Adding -baseUrl ${GITHUB_SERVER_URL} was the only change I needed to make. https://github.com/bigjew92/go-release-action/commit/18fcd46d9b9ed828a0eae48ddb390c886af3d846

wangyoucao577 commented 2 months ago

Looking for this as well. Looks like GITHUB_API_URL and GITHUB_SERVER_URL get exposed to the job, so might not need to add an extra option. Checked here: https://docs.github.com/en/actions/learn-github-actions/variables and also on the output from one of our runners jobs where this was failing.

GITHUB_SERVER_URL=https://git.mycompany.com/ GITHUB_API_URL=https://git.mycompany.com/api/v3

Tested with an internal repository to my enterprise instance. Adding -baseUrl ${GITHUB_SERVER_URL} was the only change I needed to make. bigjew92@18fcd46

Nice work! So set -baseUrl ${GITHUB_SERVER_URL} if ${GITHUB_SERVER_URL} != https://github.com may good enough.