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
495 stars 76 forks source link

Upload binary to asset is not working #15

Closed osmollo closed 4 years ago

osmollo commented 4 years ago

Hi,

I'm trying to build the go binary of my little repo (https://github.com/ohermosa/gorkscrew) using your github action but it crash uploading the file to github.

I get the following log of the job execution:

Run wangyoucao577/go-release-action@master
  with:
    github_token: ***
    goos: linux
    goarch: amd64
    goversion: https://dl.google.com/go/go1.14.7.linux-amd64.tar.gz
    pre_command: go get -v github.com/jcmturner/gokrb5/v8/client github.com/jcmturner/gokrb5/v8/config github.com/jcmturner/gokrb5/v8/credentials github.com/jcmturner/gokrb5/v8/spnego
    project_path: .

[...]

INPUT_GITHUB_TOKEN=***
_=/usr/bin/env
++ basename ohermosa/gorkscrew
+ BINARY_NAME=gorkscrew
+ '[' x '!=' x ']'
++ basename refs/heads/master
+ RELEASE_TAG=master
+ RELEASE_ASSET_NAME=gorkscrew-master-linux-amd64
++ jq -r .release.upload_url
++ cat /github/workflow/event.json
+ RELEASE_ASSETS_UPLOAD_URL=null
+ RELEASE_ASSETS_UPLOAD_URL=null

[...]

+ cd .
++ date +%s
+ BUILD_ARTIFACTS_FOLDER=build-artifacts-XXXXXXXXX
+ mkdir -p build-artifacts-XXXXXXXXX
+ GOOS=linux
+ GOARCH=amd64
+ go build -o build-artifacts-XXXXXXXXX/gorkscrew ''
+ '[' '!' -z '' ']'
+ cd build-artifacts-XXXXXXXXX
+ ls -lha
total 11M
drwxr-xr-x 2 root root 4.0K Sep  2 13:28 .
drwxr-xr-x 6 1001  116 4.0K Sep  2 13:28 ..
+ RELEASE_ASSET_EXT=.tar.gz
-rwxr-xr-x 1 root root  11M Sep  2 13:28 gorkscrew
+ '[' linux == windows ']'
+ tar cvfz gorkscrew-master-linux-amd64.tar.gz gorkscrew
gorkscrew
++ md5sum gorkscrew-master-linux-amd64.tar.gz
++ cut -d ' ' -f 1
+ MD5_SUM=59cb15626e6d709290f0899150bab9ba
+ curl --fail -X POST --data-binary @gorkscrew-master-linux-amd64.tar.gz -H 'Content-Type: application/gzip' -H 'Authorization: Bearer ***' 'null?name=gorkscrew-master-linux-amd64.tar.gz'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: null

I guess the problem is in this part:

++ jq -r .release.upload_url
++ cat /github/workflow/event.json
+ RELEASE_ASSETS_UPLOAD_URL=null
+ RELEASE_ASSETS_UPLOAD_URL=null

Where from this file event.json is?

Thanks and best regards

osmollo commented 4 years ago

I've seen in #12 which one was my problem, the trigger.

I've changed my jobs:

But it's not working, github only run the release.yml jobs. However, I already know what my mistake was

Thanks and best regards

wangyoucao577 commented 4 years ago

The release: types: [created] event will be triggerred when you create a new release on https://github.com/ohermosa/gorkscrew/releases, so that the new created release will be the target storage for the built binaries. Also, below items are not necessary in your https://github.com/ohermosa/gorkscrew/blob/master/.github/workflows/go_release.yml:

Please remove them, and try to create a new release page to see its running.

osmollo commented 4 years ago

Thank you very much!

I've deleted both items (i forget to clean useless in the last commit) but the workflow go_release.yml is not executed after create the new release.

image

That's other problem that i will have to debug

Again, thank you very much for your help. I'll close the issue

Regards

osmollo commented 4 years ago

It finally works!! This is what i have done if it helps another users:

I found this post. Basically, with the default github token has the limitation that one workflow can't run another one. I've create my own token and save it in "secrets" section. I have used it in both workflows (create_release and go_build) and it works!

Thank yo so much again

eryajf commented 1 year ago

I use https://github.com/release-drafter/release-drafter to build release automatically, and although I have used a custom configured token, I still can't build binary properly