Giter Club home page Giter Club logo

go-release-action's Introduction

Go Release GitHub Action

Build Docker PR Build Test
Automatically publish Go binaries to Github Release Assets through Github Action.

Features

  • Build Go binaries for release and publish to Github Release Assets.
  • Customizable Go versions. latest by default.
  • Support different Go project path in repository.
  • Support multiple binaries in same repository.
  • Customizable binary name.
  • Support multiple GOOS/GOARCH build in parallel by Github Action Matrix Strategy gracefully.
  • Publish .zip for windows and .tar.gz for Unix-like OS by default, optionally to disable the compression.
  • No musl library dependency issue on linux.
  • Support extra command that will be executed before go build. You may want to use it to solve dependency if you're NOT using Go Modules.
  • Rich parameters support for go build(e.g. -ldflags, etc.).
  • Support package extra files into artifacts (e.g., LICENSE, README.md, etc).
  • Support customize build command, e.g., use packr2(packr2 build) instead of go build. Another important usage is to use make(Makefile) for building on Unix-like systems.
  • Support optional .md5 along with artifacts.
  • Support optional .sha256 along with artifacts.
  • Customizable release tag to support publish binaries per push or workflow_dispatch(manually trigger).
  • Support overwrite assets if it's already exist.
  • Support customizable asset names.
  • Support private repositories.
  • Support executable compression by upx.
  • Support retry if upload phase fails.
  • Support build multiple binaries and include them in one package(.zip/.tar.gz).

Usage

Basic Example

# .github/workflows/release.yaml

on:
  release:
    types: [created]

permissions:
    contents: write
    packages: write

jobs:
  release-linux-amd64:
    name: release linux/amd64
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: wangyoucao577/go-release-action@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: linux
        goarch: amd64

Input Parameters

Parameter Mandatory/Optional Description
github_token Mandatory Your GITHUB_TOKEN for uploading releases to Github assets.
goos Mandatory GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
goarch Mandatory GOARCH is the running program's architecture target: one of 386, amd64, arm, arm64, s390x, loong64 and so on.
goamd64 Optional GOAMD64 is the running programs amd64 microarchitecture level, which is available since go1.18. It should only be used when GOARCH is amd64: one of v1, v2, v3, v4.
goarm Optional GOARM is the running programs arm microarchitecture level, which is available since go1.1. It should only be used when GOARCH is arm: one of 5, 6, 7,
goversion Optional The Go compiler version. latest(check it here) by default, optional 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19. You can also define a specific minor release, such as 1.19.5.
Alternatively takes a download URL or a path to go.mod instead of version string. Make sure your URL references the linux-amd64 package. You can find the URL on Go - Downloads.
e.g., https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz.
project_path Optional Where to run go build.
Use . by default.
If enable multi_binaries: true, you can use project_path: ./cmd/... or project_path: ./cmd/app1 ./cmd/app2 to build multiple binaries and include them in one package.
binary_name Optional Specify another binary name if do not want to use repository basename.
Use your repository's basename if not set.
pre_command Optional Extra command that will be executed before go build. You may want to use it to solve dependency if you're NOT using Go Modules.
build_command Optional The actual command to build binary, typically go build. You may want to use other command wrapper, e.g., packr2, example build_command: 'packr2 build'. Remember to use pre_command to set up packr2 command in this scenario.
It also supports the make(Makefile) building system, example build_command: make. In this case both build_flags and ldflags will be ignored since they should be written in your Makefile already. Also, please make sure the generated binary placed in the path where make runs, i.e., project_path.
executable_compression Optional Compression executable binary by some third-party tools. It takes compression command with optional args as input, e.g., upx or upx -v.
Only upx is supported at the moment.
build_flags Optional Additional arguments to pass the go build command.
ldflags Optional Values to provide to the -ldflags argument.
extra_files Optional Extra files that will be packaged into artifacts either. Multiple files separated by space. Note that extra folders can be allowed either since internal cp -r already in use.
E.g., extra_files: LICENSE README.md
md5sum Optional Publish .md5 along with artifacts, TRUE by default.
sha256sum Optional Publish .sha256 along with artifacts, FALSE by default.
release_tag Optional Target release tag to publish your binaries to. It's dedicated to publish binaries on every push into one specified release page since there's no target in this case. DON'T set it if you trigger the action by release: [created] event as most people do.
release_name Optional Alternative to release_tag for release target specification and binary push. The newest release by given release_name will be picked from all releases. Useful for e.g. untagged(draft) ones.
release_repo Optional Repository where the build should be pushed to. By default the value for this is the repo from where the action is running. Useful if you use a different repository for your releases (private repo for code, public repo for releases).
overwrite Optional Overwrite asset if it's already exist. FALSE by default.
asset_name Optional Customize asset name if do not want to use the default format ${BINARY_NAME}-${RELEASE_TAG}-${GOOS}-${GOARCH}.
Make sure set it correctly, especially for matrix usage that you have to append -${{ matrix.goos }}-${{ matrix.goarch }}. A valid example could be asset_name: binary-name-${{ matrix.goos }}-${{ matrix.goarch }}.
retry Optional How many times retrying if upload fails. 3 by default.
post_command Optional Extra command that will be executed for teardown work. e.g. you can use it to upload artifacts to AWS s3 or aliyun OSS
compress_assets Optional auto default will produce a zip file for Windows and tar.gz for others. zip will force the use of zip. OFF will disable packaging of assets.
upload Optional Upload release assets or not. It'll be useful if you'd like to use subsequent workflow to process the file, such as signing it on macos, and so on.

Output Parameters

Parameter Description
release_asset_dir Release file directory provided for use by other workflows.

Advanced Example

  • Release for multiple OS/ARCH in parallel by matrix strategy.
  • Go code is not in . of your repository.
  • Customize binary name.
  • Use go 1.13.1 from downloadable URL instead of the default version.
  • Package extra LICENSE and README.md into artifacts.
# .github/workflows/release.yaml

on:
  release:
    types: [created]

permissions:
    contents: write
    packages: write

jobs:
  releases-matrix:
    name: Release Go Binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
        goos: [linux, windows, darwin]
        goarch: ["386", amd64, arm64]
        exclude:
          - goarch: "386"
            goos: darwin
          - goarch: arm64
            goos: windows
    steps:
    - uses: actions/checkout@v4
    - uses: wangyoucao577/go-release-action@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: ${{ matrix.goos }}
        goarch: ${{ matrix.goarch }}
        goversion: "https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz"
        project_path: "./cmd/test-binary"
        binary_name: "test-binary"
        extra_files: LICENSE README.md

More Examples

Welcome share your usage for other people's reference!

πŸ‘πŸ‘πŸ‘ Enjoy! Welcome star if like itπŸ˜„

go-release-action's People

Contributors

1efty avatar a-bali avatar alexbacchin avatar bcrochet avatar cetteup avatar debugtalk avatar dependabot-preview[bot] avatar erfantkerfan avatar f0o avatar flemeur avatar fscarmen avatar fupengl avatar hmiyado avatar kmlebedev avatar lslqtz avatar malud avatar mcuadros avatar mjmayer avatar paketb0te avatar parkerduckworth avatar raykov avatar rustydb avatar serafdev avatar simple-tracker avatar spuder avatar systemfiles avatar tuxdude avatar wangyoucao577 avatar wsine avatar zxilly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-release-action's Issues

RELEASE_ASSETS_UPLOAD_URL=null

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

  • RELEASE_ASSETS_UPLOAD_URL=null
  • RELEASE_ASSETS_UPLOAD_URL=null

Upload binary to asset is not working

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

Failing tag is mandatory but not set

My code look like this , but its failing due to tag not set

# .github/workflows/release.yaml

on: 
  release:
    types: [created]

jobs:
  releases-matrix:
    name: Release Go Binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
        goos: [linux, windows, darwin]
        goarch: ["386", amd64, arm64]
        exclude:
          - goarch: "386"
            goos: darwin
          - goarch: arm64
            goos: windows
    steps:
    - uses: actions/checkout@v2
    - uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.ACCESS_TOKEN }}
        goos: ${{ matrix.goos }}
        goarch: ${{ matrix.goarch }}
        goversion: "https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz"

releasing on git tag

Is there a way to pass in the release name? I don't want to have to manually create releases, I want to be able to push to a git tag, automatically create a release, and then upload binaries to it.

I tried using two separate actions, one that creates a release and then a separate one that is triggered on release. The second action was never actually triggered but I'd rather not work around the core issue anyway, I want it to be in one job.

the following action gets the curl: (6) Could not resolve host: null error.

name: Build and Release Binaries

on:
  push:
    tags:
    # Push events to matching v*, i.e. v1.0, v20.15.10
    - 'v*'

jobs:
 create-release:
    runs-on: ubuntu-latest
    steps:
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: ${{ github.ref }}
        body: |
          Release ${{ github.ref }}
        draft: false
        prerelease: false

  build-and-release-github:
    needs: [create-release]
    name: Release Go Binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        goos: [linux, windows, darwin]
        goarch: [amd64]
    steps:
    - uses: actions/checkout@v2
    - name: Go Release Binaries
      uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: ${{ matrix.goos }}
        goarch: ${{ matrix.goarch }}
        goversion: "https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz"
        project_path: "./client"
        binary_name: "client"
        build_flags: -v

Turn off Compression

Hello @wangyoucao577

Looking over the release.sh code it seems there is no way to turn off compression completely and just have the go binary uploaded by itself.

I'm not sure the best way to implement this but it would be nice for my project to not have the single go binary wrapped up in a tarball so users can just download the binary directly without needing to untar it first.

Thoughts?

github-assets-uploader failed after retry 3 times

version: wangyoucao577/[email protected]

Go.mod file not found and strange volume mount

I have the following error

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

Also I notice a strange volume mounting when starting the action, with a duplicate folder name, the log is

/usr/bin/docker run --name ghcriowangyoucao577goreleaseactionv122_617224 --label 6a6825 --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_GOOS -e INPUT_GOARCH -e INPUT_GOVERSION -e INPUT_EXTRA_FILES -e INPUT_BUILD_FLAGS -e INPUT_LDFLAGS -e INPUT_PROJECT_PATH -e INPUT_BINARY_NAME -e INPUT_PRE_COMMAND -e INPUT_BUILD_COMMAND -e INPUT_EXECUTABLE_COMPRESSION -e INPUT_MD5SUM -e INPUT_SHA256SUM -e INPUT_RELEASE_TAG -e INPUT_OVERWRITE -e INPUT_ASSET_NAME -e INPUT_RETRY -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/krakend-cached-router/krakend-cached-router":"/github/workspace" ghcr.io/wangyoucao577/go-release-action:v1.22  "***" "linux" "amd64" "https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz" "" "" "." "" "" "go build" "" "LICENSE README.md" "TRUE" "FALSE" "" "FALSE" "" "3"

with the interested part
-v "/home/runner/work/krakend-cached-router/krakend-cached-router":"/github/workspace"

My config is:

name: Build
on: 
  release:
    types: [created]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Build and deploy artifact
      uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
        goos: linux
        goarch: amd64
        goversion: "https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz"
        extra_files: LICENSE README.md
        build_flags: --buildmode=plugin

Other failing tests I did:

  • remove build_flags: --buildmode=plugin
  • project_path: ".."

My source code is inside the repository root, what I am doing wrong?

Customizable asset name

Currently asset name format is ${BINARY_NAME}-${RELEASE_TAG}-${INPUT_GOOS}-${INPUT_GOARCH} by default. But people may want to add something else in the name, e.g., date or shortsha, etc.

Update the binary on every master commit

Related to #11
The binary is only built on release.

I want to update a binary on every master commit, so that non-Golang users are able to get a binary executable.

Weekly releasing is not fast enough for some non-Golang users.

write: connection reset by peer

Hi youcao, thanks for your great work.

I came across a random error:

Post "https://uploads.github.com/repos/ioogle/xxx/releases/52036860/assets?name=xxx-api-v0.0.4-darwin-amd64.tar.gz": write tcp 172.17.0.2:39572->140.82.114.13:443: write: connection reset by peer

But sometimes it works fine.

This is the action:

name: Release Go Binaries

on:
  release:
    types: [created]
  workflow_dispatch:

jobs:
  release:
    runs-on: ubuntu-18.04
    env:
      GOPRIVATE: github.com/ioogle
    strategy:
      matrix:
        goos: [linux, darwin]
        goarch: [amd64]
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Set BUILD_TIME env
        run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}

      - name: Environment Printer
        uses: managedkaos/[email protected]

      - name: Build Go Binary
        uses: wangyoucao577/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          project_path: "./cmd/api"
          binary_name: "xxx-api"
          pre_command: "cd ./xxx; git config --global url.\"https://ioogle:${{ secrets.ACCESS_TOKEN }}@github.com\".insteadOf \"https://github.com\"; go mod download"
          ldflags: -X "main.appVersion=${{ github.event.release.tag_name }}" -X "main.buildTime=${{ env.BUILD_TIME }}" -X main.gitCommit=${{ github.sha }} -X main.gitRef=${{ github.ref }}
          asset_name: xxx-api-${{ github.event.release.tag_name }}-${{ matrix.goos }}-${{ matrix.goarch }}

Failed to upload asset

/usr/bin/docker run --name ghcriowangyoucao577goreleaseactionv125_bf049b --label 29a95e --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_GOOS -e INPUT_GOARCH -e INPUT_GOVERSION -e INPUT_PROJECT_PATH -e INPUT_BINARY_NAME -e INPUT_EXTRA_FILES -e INPUT_BUILD_FLAGS -e INPUT_LDFLAGS -e INPUT_PRE_COMMAND -e INPUT_BUILD_COMMAND -e INPUT_EXECUTABLE_COMPRESSION -e INPUT_MD5SUM -e INPUT_SHA256SUM -e INPUT_RELEASE_TAG -e INPUT_RELEASE_NAME -e INPUT_OVERWRITE -e INPUT_ASSET_NAME -e INPUT_RETRY -e INPUT_POST_COMMAND -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/certgen/certgen":"/github/workspace" ghcr.io/wangyoucao577/go-release-action:v1.25 "***" "linux" "amd64" "1.17" "" "" "." "certgen" "" "go build" "" "LICENSE README.md" "TRUE" "FALSE" "" "" "FALSE" "" "3" ""

  • source /setup-go.sh
    +++ curl 'https://go.dev/VERSION?m=text'
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed

    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
    100 8 100 8 0 0 54 0 --:--:-- --:--:-- --:--:-- 54
    ++ GO_LINUX_PACKAGE_URL=https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz
    ++ [[ 1.17 == \1.\1\7 ]]
    ++ GO_LINUX_PACKAGE_URL=https://go.dev/dl/go1.17.linux-amd64.tar.gz
    ++ wget --progress=dot:mega https://go.dev/dl/go1.17.linux-amd64.tar.gz -O go-linux.tar.gz
    --2022-03-11 14:21:47-- https://go.dev/dl/go1.17.linux-amd64.tar.gz
    Resolving go.dev (go.dev)... 216.239.38.21, 216.239.36.21, 216.239.34.21, ...
    Connecting to go.dev (go.dev)|216.239.38.21|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: https://dl.google.com/go/go1.17.linux-amd64.tar.gz [following]
    --2022-03-11 14:21:47-- https://dl.google.com/go/go1.17.linux-amd64.tar.gz
    Resolving dl.google.com (dl.google.com)... 142.250.138.93, 142.250.138.136, 142.250.138.190, ...
    Connecting to dl.google.com (dl.google.com)|142.250.138.93|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 134787877 (129M) [application/x-gzip]
    Saving to: 'go-linux.tar.gz'

    0K ........ ........ ........ ........ ........ ........ 2% 48.2M 3s
    3072K ........ ........ ........ ........ ........ ........ 4% 132M 2s
    6144K ........ ........ ........ ........ ........ ........ 7% 33.7M 2s
    9216K ........ ........ ........ ........ ........ ........ 9% 197M 2s
    12288K ........ ........ ........ ........ ........ ........ 11% 28.2M 2s
    15360K ........ ........ ........ ........ ........ ........ 14% 164M 2s
    18432K ........ ........ ........ ........ ........ ........ 16% 39.4M 2s
    21504K ........ ........ ........ ........ ........ ........ 18% 54.4M 2s
    24576K ........ ........ ........ ........ ........ ........ 21% 118M 2s
    27648K ........ ........ ........ ........ ........ ........ 23% 54.4M 2s
    30720K ........ ........ ........ ........ ........ ........ 25% 64.1M 2s
    33792K ........ ........ ........ ........ ........ ........ 28% 203M 2s
    36864K ........ ........ ........ ........ ........ ........ 30% 30.5M 2s
    39936K ........ ........ ........ ........ ........ ........ 32% 149M 1s
    43008K ........ ........ ........ ........ ........ ........ 35% 38.0M 1s
    46080K ........ ........ ........ ........ ........ ........ 37% 85.7M 1s
    49152K ........ ........ ........ ........ ........ ........ 39% 66.2M 1s
    52224K ........ ........ ........ ........ ........ ........ 42% 38.9M 1s
    55296K ........ ........ ........ ........ ........ ........ 44% 203M 1s
    58368K ........ ........ ........ ........ ........ ........ 46% 28.4M 1s
    61440K ........ ........ ........ ........ ........ ........ 49% 192M 1s
    64512K ........ ........ ........ ........ ........ ........ 51% 25.4M 1s
    67584K ........ ........ ........ ........ ........ ........ 53% 183M 1s
    70656K ........ ........ ........ ........ ........ ........ 56% 44.3M 1s
    73728K ........ ........ ........ ........ ........ ........ 58% 85.4M 1s
    76800K ........ ........ ........ ........ ........ ........ 60% 35.0M 1s
    79872K ........ ........ ........ ........ ........ ........ 63% 199M 1s
    82944K ........ ........ ........ ........ ........ ........ 65% 43.2M 1s
    86016K ........ ........ ........ ........ ........ ........ 67% 63.0M 1s
    89088K ........ ........ ........ ........ ........ ........ 70% 111M 1s
    92160K ........ ........ ........ ........ ........ ........ 72% 70.2M 1s
    95232K ........ ........ ........ ........ ........ ........ 74% 36.9M 1s
    98304K ........ ........ ........ ........ ........ ........ 77% 202M 1s
    101376K ........ ........ ........ ........ ........ ........ 79% 42.6M 0s
    104448K ........ ........ ........ ........ ........ ........ 81% 64.4M 0s
    107520K ........ ........ ........ ........ ........ ........ 84% 57.0M 0s
    110592K ........ ........ ........ ........ ........ ........ 86% 64.9M 0s
    113664K ........ ........ ........ ........ ........ ........ 88% 93.2M 0s
    116736K ........ ........ ........ ........ ........ ........ 91% 57.3M 0s
    119808K ........ ........ ........ ........ ........ ........ 93% 94.5M 0s
    122880K ........ ........ ........ ........ ........ ........ 95% 17.2M 0s
    125952K ........ ........ ........ ........ ........ ........ 98% 156M 0s
    129024K ........ ........ ........ ........ ........ 100% 49.2M=2.3s

2022-03-11 14:21:50 (56.5 MB/s) - 'go-linux.tar.gz' saved [134787877/134787877]

++ tar -zxf go-linux.tar.gz
++ mv go /usr/local/
++ mkdir -p /go/bin /go/src /go/pkg
++ export GO_HOME=/usr/local/go
++ GO_HOME=/usr/local/go
++ export GOPATH=/go
++ GOPATH=/go
++ export PATH=/go/bin:/usr/local/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/go/bin:/usr/local/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

  • go version
  • env
    go version go1.17 linux/amd64
  • /release.sh
    INPUT_GOARCH=amd64
    INPUT_RETRY=3
    INPUT_GOVERSION=1.17
    HOSTNAME=c9910563b33a
    GITHUB_REF_NAME=v0.1.0
    INPUT_ASSET_NAME=
    GITHUB_API_URL=https://api.github.com
    INPUT_PROJECT_PATH=.
    INPUT_MD5SUM=TRUE
    GITHUB_STEP_SUMMARY=/github/file_commands/step_summary_b00f0c9f-8263-46b7-bc9e-ac33ac14836b
    GITHUB_RUN_ATTEMPT=1
    RUNNER_TOOL_CACHE=/opt/hostedtoolcache
    GITHUB_REPOSITORY_OWNER=danvixent
    GITHUB_ACTIONS=true
    CI=true
    GITHUB_HEAD_REF=
    GITHUB_ACTOR=danvixent
    GITHUB_ACTION_REF=v1.25
    INPUT_OVERWRITE=FALSE
    GOPATH=/go
    GITHUB_ACTION=__wangyoucao577_go-release-action
    INPUT_BINARY_NAME=certgen
    GITHUB_REF_PROTECTED=false
    INPUT_POST_COMMAND=
    INPUT_LDFLAGS=

HOME=/github/home
INPUT_BUILD_FLAGS=
GITHUB_ACTION_REPOSITORY=wangyoucao577/go-release-action
GITHUB_REF_TYPE=tag
++ basename danvixent/certgen
RUNNER_TEMP=/home/runner/work/_temp
GITHUB_RETENTION_DAYS=90
INPUT_EXTRA_FILES=LICENSE README.md
INPUT_RELEASE_NAME=
GITHUB_ENV=/github/file_commands/set_env_b00f0c9f-8263-46b7-bc9e-ac33ac14836b
RUNNER_WORKSPACE=/home/runner/work/certgen
GITHUB_REF=refs/tags/v0.1.0

  • BINARY_NAME=certgen
    GITHUB_SHA=51e1c7a514d1fb37a8f43f6a4755c06a88af9091
  • '[' xcertgen '!=' x ']'
    ACTIONS_RUNTIME_TOKEN=***
  • BINARY_NAME=certgen
    ++ basename refs/tags/v0.1.0
  • RELEASE_TAG=v0.1.0
  • '[' '!' -z '' ']'
  • '[' '!' -z '' ']'
  • RELEASE_NAME=
  • RELEASE_ASSET_NAME=certgen-v0.1.0-linux-amd64
  • '[' '!' -z '' ']'
  • '[' push == release ']'
  • '[' push == push ']'
  • echo 'Event: push'
  • '[' '!' -z '' ']'
  • EXT=
  • '[' linux == windows ']'
  • LDFLAGS_PREFIX=
  • '[' '!' -z '' ']'
    ++ date +%s
  • BUILD_ARTIFACTS_FOLDER=build-artifacts-1647008514
  • mkdir -p ./build-artifacts-1647008514
  • cd .
  • [[ go build =~ ^make.* ]]
  • GOOS=linux
  • GOARCH=amd64
  • go build -o build-artifacts-1647008514/certgen ''
    GITHUB_RUN_ID=1969254757
    RUNNER_ARCH=X64
    GITHUB_SERVER_URL=https://github.com
    GO_HOME=/usr/local/go
    GITHUB_EVENT_PATH=/github/workflow/event.json
    INPUT_GOOS=linux
    GITHUB_GRAPHQL_URL=https://api.github.com/graphql
    RUNNER_OS=Linux
    GITHUB_BASE_REF=
    INPUT_SHA256SUM=FALSE
    INPUT_BUILD_COMMAND=go build
    GITHUB_PATH=/github/file_commands/add_path_b00f0c9f-8263-46b7-bc9e-ac33ac14836b
    INPUT_RELEASE_TAG=
    GITHUB_JOB=release-matrix
    RUNNER_NAME=GitHub Actions 2
    INPUT_EXECUTABLE_COMPRESSION=
    SHLVL=1
    GITHUB_REPOSITORY=danvixent/certgen
    INPUT_PRE_COMMAND=
    GITHUB_EVENT_NAME=push
    GITHUB_RUN_NUMBER=1
    GITHUB_WORKFLOW=Release Go Binaries
    PATH=/go/bin:/usr/local/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    GITHUB_WORKSPACE=/github/workspace
    ACTIONS_RUNTIME_URL=https://pipelines.actions.githubusercontent.com/Ok77YWRkg9KTXsXpByBeLrItOG8jYGZzlqCWiMBBnwqM4eJmZV/
    ACTIONS_CACHE_URL=https://artifactcache.actions.githubusercontent.com/Ok77YWRkg9KTXsXpByBeLrItOG8jYGZzlqCWiMBBnwqM4eJmZV/
    INPUT_GITHUB_TOKEN=***
    _=/usr/bin/env
    Event: push
    go: downloading github.com/sirupsen/logrus v1.8.1
    go: downloading golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
  • '[' '!' -z '' ']'
  • '[' '!' -z 'LICENSE README.md' ']'
  • cd /github/workspace
  • cp -r LICENSE README.md ./build-artifacts-1647008514/
  • cd .
  • cd build-artifacts-1647008514
  • ls -lha
  • RELEASE_ASSET_EXT=.tar.gz
  • MEDIA_TYPE=application/gzip
    total 6.3M
    drwxr-xr-x 2 root root 4.0K Mar 11 14:21 .
    drwxr-xr-x 5 1001 121 4.0K Mar 11 14:21 ..
    -rw-r--r-- 1 root root 34K Mar 11 14:21 LICENSE
    -rw-r--r-- 1 root root 1.2K Mar 11 14:21 README.md
    -rwxr-xr-x 1 root root 6.3M Mar 11 14:21 certgen
  • RELEASE_ASSET_FILE=certgen-v0.1.0-linux-amd64.tar.gz
  • '[' linux == windows ']'
  • shopt -s dotglob
  • tar cvfz certgen-v0.1.0-linux-amd64.tar.gz LICENSE README.md certgen
    LICENSE
    README.md
    certgen
    ++ md5sum certgen-v0.1.0-linux-amd64.tar.gz
    ++ cut -d ' ' -f 1
  • MD5_SUM=9d8a0c299de3602a52b67aef73ec81ef
    ++ sha256sum certgen-v0.1.0-linux-amd64.tar.gz
    ++ cut -d ' ' -f 1
  • SHA256_SUM=73776f46b5a72c82586b39ab7ef0b4cec1ad40cc2313512db4180d2e074baaab
  • GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS=
  • '[' FALSE == TRUE ']'
  • github-assets-uploader -logtostderr -f certgen-v0.1.0-linux-amd64.tar.gz -mediatype application/gzip -repo danvixent/certgen -token *** -tag=v0.1.0 -releasename= -retry 3
    W0311 14:21:56.610551 101 main.go:58] Upload asset error, will retry in 3s: GET https://api.github.com//repos/danvixent/certgen/releases/tags/v0.1.0: 404 Not Found []
    W0311 14:21:59.722105 101 main.go:58] Upload asset error, will retry in 3s: GET https://api.github.com/repos/danvixent/certgen/releases/tags/v0.1.0: 404 Not Found []
    E0311 14:22:02.834961 101 main.go:21] GET https://api.github.com/repos/danvixent/certgen/releases/tags/v0.1.0: 404 Not Found []

The action keeps failing to upload assets, any help is appreciated !

need post_command feature to do some teardown work

I want to do some teardown work after releasing, such as publishing artifacts to aliyun OSS as well.

However, when I do this work in next step, I can not get BUILD_ARTIFACTS_FOLDER environment as they are in different steps. Thus I think it maybe useful if we can have a new post_command feature like pre_command.

Code Signing?

How could code-signing be added to the ci process? Particularly for macOS code signing is relevant.

Option to skip archiving

Thank you for this project.

In some cases, e.g., when releasing only the binary file, it may be useful to release the files without archiving them to a .tar.gz or .zip first. In such cases, the files can be uploaded directly as individual files, following the asset naming convention.

What permissions are required by this action?

I tried running this action with the following permissions:

    permissions:
      packages: write
on:
  release:
    types: [created]


jobs:
  releases-matrix:
    permissions:
      packages: write
    name: Release Go Binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # build and publish in parallel: linux/amd64, linux/arm64, windows/amd64, darwin/amd64, darwin/arm64
        goos: [linux, windows, darwin]
        goarch: [amd64, arm64]
        exclude:
          - goarch: arm64
            goos: windows
    steps:
    - uses: actions/checkout@v3
    - uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: ${{ matrix.goos }}
        goarch: ${{ matrix.goarch }}
        goversion: 1.18
        extra_files: LICENSE.md README.md

and it failed.

github-assets-uploader -logtostderr -f auspinner-0.1.0-windows-amd64.zip -mediatype application/zip -repo 2color/auspinner -token *** -tag=0.1.0 -releasename= -retry 3
W0623 08:54:51.996698    3056 main.go:58] Upload asset error, will retry in 3s: Post 

What are the necessary permissions for this to run?

UPX support?

Can you make support for automatic packing of executable files via UPX?

curl 'https://golang.org/VERSION?m=text' returns <a href="https://go.dev/VERSION?m=text">Moved Permanently</a>

Hello, thank you for the cool release action.

I faced this issue when try to use latest version of Golang

      - uses: wangyoucao577/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          goos: linux
          goarch: amd64
          goversion: 1.17.3
+ source /setup-go.sh
+++ curl 'https://golang.org/VERSION?m=text'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    64  100    64    0     0    593      0 --:--:-- --:--:-- --:--:--   598
++ GO_LINUX_PACKAGE_URL='https://dl.google.com/go/<a href="https://go.dev/VERSION?m=text">Moved Permanently</a>..linux-amd64.tar.gz'
++ [[ 1.17.3 == \1\.\1\7 ]]
++ [[ 1.17.3 == \1\.\1\6 ]]
++ [[ 1.17.3 == \1\.\1\5 ]]
++ [[ 1.17.3 == \1\.\1\4 ]]
++ [[ 1.17.3 == \1\.\1\3 ]]
++ [[ 1.17.3 == http* ]]
++ wget --progress=dot:mega 'https://dl.google.com/go/<a' 'href="https://go.dev/VERSION?m=text">Moved' 'Permanently</a>..linux-amd64.tar.gz' -O go-linux.tar.gz
--2021-11-22 20:39:47--  https://dl.google.com/go/%3Ca
Resolving dl.google.com (dl.google.com)... 142.250.68.14, 2607:f8b0:4007:80d::200e
Connecting to dl.google.com (dl.google.com)|142.250.68.14|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-11-22 20:39:47 ERROR 404: Not Found.

href="https://go.dev/VERSION?m=text">Moved: Scheme missing.
--2021-11-22 20:39:47--  http://permanently%3C/a%3E..linux-amd64.tar.gz
Resolving permanently< (permanently<)... failed: Name or service not known.
wget: unable to resolve host address 'permanently<'

PR to fix this issue #67

Alpine Linux muslc build support

This is the workflow I currently have to publish builds:

on: 
  release:
    types: [created]

jobs:
  releases-matrix:
    name: Release Go Binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # build and publish in parallel: linux, windows and macos 32 and 64-bit x86
        goos: [linux, windows, darwin]
        goarch: [386, amd64]
    steps:
    - uses: actions/checkout@v2
    - uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: ${{ matrix.goos }}
        goarch: ${{ matrix.goarch }}
        extra_files: LICENSE README.md
        sha256sum: false
        md5sum: false

The amd64 linux build does not run on alpine however because it uses muslc instead of glibc. Would it be possible to support this somehow or would I have to create a second job with runs-on: alpine-latest

Support build from Makefile or free-form build_command

I am very thankful to see the great action helping us to release GO artifacts.

However, I already have a Makefile to build my binary with the application version information injection in the Makefile.

Examples:

LDFLAGS += -X my-module/hvalues.tagVersion=${VERSION}
LDFLAGS += -X my-module/hvalues.gitCommit=${GIT_COMMIT}
LDFLAGS += -X my-module/hvalues.gitTreeState=${GIT_DIRTY}
LDFLAGS += $(EXT_LDFLAGS)

work around

My Makefile https://github.com/qrtt1/helm-values/blob/v0.1/Makefile

I know the action supports the LDFLAGS flag, but it doesn't make sense to duplicate LDFLAGS twice in the project.

It would be better to support a free-form build command to leverage existing build scripts or Makefile.

For now, I work around it:

     - uses: wangyoucao577/[email protected]
	 with:
	 github_token: ${{ secrets.GITHUB_TOKEN }}
	 goos: ${{ matrix.goos }}
	 goarch: ${{ matrix.goarch }}
	 build_command: "make"
	 build_flags: "all"
	 binary_name: "helm-values"
	 ldflags: "-I."
	 extra_files: LICENSE README.md helm-values

Invalid usage of empty arguments using `go build path_to_filename`

LDFLAGS_PREFIX=''
if [ ! -z "${INPUT_LDFLAGS}" ]; then
LDFLAGS_PREFIX="-ldflags"
fi
# build
cd ${INPUT_PROJECT_PATH}
BUILD_ARTIFACTS_FOLDER=build-artifacts-$(date +%s)
mkdir -p ${BUILD_ARTIFACTS_FOLDER}
GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} ${INPUT_BUILD_COMMAND} -o ${BUILD_ARTIFACTS_FOLDER}/${BINARY_NAME}${EXT} ${INPUT_BUILD_FLAGS} ${LDFLAGS_PREFIX} "${INPUT_LDFLAGS}"

If you do not specify any LDFLAGS it's will generate an empty argument '' and therefore the action will not be able to build

eg:

- name: Go Release Binaries
        uses: wangyoucao577/[email protected]
        with:
          goversion: 1.16
          github_token: ${{ secrets.GITHUB_TOKEN }}
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          release_tag: dev
          overwrite: true
          build_flags: cmd/mm2_tools_server.go
          binary_name: mm2-tools-server

Will generate invalid command line with a '' extra args.

go build -o build-artifacts-1626343191/mm2-tools-server cmd/mm2_tools_server.go ''

Capture d’écran 2021-07-15 aΜ€ 12 08 33

GOROOT not found

here there, as the title suggests, I get the following error when trying to release a new binary:

Go Release Binaries                          13s
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.14.6/x64
 79872K ........ ........ ........ ........ ........ ........ 68%  155M 0s
 82944K ........ ........ ........ ........ ........ ........ 71%  146M 0s
 86016K ........ ........ ........ ........ ........ ........ 73%  138M 0s
 89088K ........ ........ ........ ........ ........ ........ 76%  127M 0s
 92160K ........ ........ ........ ........ ........ ........ 78%  142M 0s
 95232K ........ ........ ........ ........ ........ ........ 81%  139M 0s
 98304K ........ ........ ........ ........ ........ ........ 84%  153M 0s
101376K ........ ........ ........ ........ ........ ........ 86%  144M 0s
104448K ........ ........ ........ ........ ........ ........ 89%  162M 0s
107520K ........ ........ ........ ........ ........ ........ 91%  149M 0s
110592K ........ ........ ........ ........ ........ ........ 94%  165M 0s
113664K ........ ........ ........ ........ ........ ........ 96%  141M 0s
116736K ........ ........ ........ ........ ........ ........ 99%  135M 0s
119808K ........ .....                                       100%  147M=1.0s

2020-08-06 10:28:57 (123 MB/s) - 'go-linux.tar.gz' saved [123550266/123550266]

++ tar -zxf go-linux.tar.gz
++ mv go /usr/local/
++ mkdir -p /go/bin /go/src /go/pkg
++ export GO_HOME=/usr/local/go
++ GO_HOME=/usr/local/go
++ export PATH=/usr/local/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/usr/local/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export GOPATH=/go
++ GOPATH=/go
+ go version
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.14.6/x64

is there a way to fix it? or is it just my configuration? here is also my yaml file:

name: Go

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

      - name: Set up Go 1.14
        uses: actions/setup-go@v2
        with:
          go-version: ^1.14
        id: go

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2

      - name: Get dependencies
        run: |
          go get -v -t -d ./...
          if [ -f Gopkg.toml ]; then
              curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
              dep ensure
          fi

      - name: Build
        run: go build -v .

      - name: Test
        run: go test -v .

      - name: Go Release Binaries
        uses: wangyoucao577/[email protected]

github-assets-uploader very often fails

Currently the upload very often fails at github-assets-uploader. (Previously it was working fine.)

https://github.com/chrislusf/seaweedfs/runs/4107363083?check_suite_focus=true

Sometimes it can run partially after serveral retries: https://github.com/chrislusf/seaweedfs/actions/runs/1422094429

+ tar cvfz weed-large-disk-20211104-1601-linux-amd64.tar.gz weed-large-disk
weed-large-disk
++ md5sum weed-large-disk-20211104-1601-linux-amd64.tar.gz
++ cut -d ' ' -f 1
+ MD5_SUM=fd5586ddecc22fd85307d9081bec4a12
++ sha256sum weed-large-disk-20211104-1601-linux-amd64.tar.gz
++ cut -d ' ' -f 1
+ SHA256_SUM=71e73515078143412eb9db170d6a28d48f3a82cbe854d6e7fcfa9971b173da94
+ GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS=
+ '[' TRUE == TRUE ']'
+ GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS=-overwrite
+ github-assets-uploader -f weed-large-disk-20211104-1601-linux-amd64.tar.gz -mediatype application/gzip -overwrite -repo chrislusf/seaweedfs -token *** -tag dev
Post "https://uploads.github.com/repos/chrislusf/seaweedfs/releases/52499161/assets?name=weed-large-disk-20211104-1601-linux-amd64.tar.gz": unexpected EOF

Action doesn't run on release created by other action

I have a repository (https://github.com/albertodonato/h2static/actions) with the following actions set up:

  • a workflow using actions/create-release to create releases based on x.y.z tags
  • a workflow using go-release-action to build and publish go binaries to the created release

I'm using the standard

on:
  release:
    types:
      - created

to trigger the latter.

For some reason, the go-release-action doesn't seem to be triggered for releases created by create-release.
If I manually create a release through the UI, then it works.

I suspect it might be something wrong with my setup, but I can't figure out what.

Any pointers on how to debug or fix the issue?

Thanks

Typo in the README, 'asserts' instead of 'assets'

In the README, the following line in the first row of the table:

Your GITHUB_TOKEN for uploading releases to Github asserts.

should instead be:

Your GITHUB_TOKEN for uploading releases to Github assets.

Sent pull request #74 with the fix.

Recommended approach to build module which imports private modules

When using this action to build go modules which imports other private go modules what is the recommended approach to set

  • GOPRIVATE to explicitly mark an import as private
  • Set git credentials to allow the go get of such private imports?

Usually when building go modules inside docker containers I place in the Dockerfile the following commands which pulls the credentials from flags in the docker build command.

# git is required to fetch go dependencies
RUN apk add --no-cache ca-certificates git

RUN echo "machine github.com  login $ACCESS_TOKEN_USR password $ACCESS_TOKEN_PWD  machine api.github.com  login $ACCESS_TOKEN_USR password $ACCESS_TOKEN_PWD"  >> /root/.netrc

RUN go env -w GOPRIVATE=github.com/indisrl

Change asset_name of only one item in matrix?

How do I change only "darwin"'s asset_name?

My users are not going to understand "darwin", so I wanted to change it to "macos" - something like:

      matrix:
        goos: [linux, windows, darwin]
        goarch: [amd64, arm64]
        exclude:
          - goos: windows
            goarch: arm64

    steps:
      - uses: actions/checkout@v2
     - uses: wangyoucao577/[email protected]
        with:
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          if: ${{ matrix.goos }} == 'darwin'
            asset_name: "${BINARY_NAME}-${RELEASE_TAG}-macos-${{ matrix.goarch }}"

Obviously this doesn't work since I can't use an if there. Is there a clean way to do this?

Thank you!

How to build multiple binaries and create multiple artifacts for them ?

Hello i read the documentation but not sure how to achieve this one:

  • one server to build
  • one client to build

and package them into 2 different artifacts

and especially how to do the equivalent of:

go build -o binary_name package_name/my_file.go ?

eg:

name: Release

on:
  push:
    branches: [ main ]

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        goos: [linux, windows, darwin, freebsd]
        goarch: [amd64]

    steps:

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2

      - name: Set BUILD_TIME env
        run: echo BUILD_TIME=$(date -u +%Y-%m-%d-%H-%M) >> ${GITHUB_ENV}

      - name: Go Release Binaries
        uses: wangyoucao577/[email protected]
        with:
          goversion: 1.16
          github_token: ${{ secrets.GITHUB_TOKEN }}
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          release_tag: dev
          overwrite: true          
          build_flags: cmd/mm2_tools_server.go
          binary_name: mm2-tools-server

Generates: go build -o build-artifacts-1626342834/mm2-tools-server cmd/mm2_tools_server.go ''

instead of go build -o build-artifacts-1626342834/mm2-tools-server cmd/mm2_tools_server.go

Seems to be a mistake

Hidden extra_files (dotfiles) are not being packaged

Hi

I have a hidden file that i want to include in the extra_files to be packaged along with the binary. This is currently not possible because the glob (*) does not include hidden files by default (here https://github.com/wangyoucao577/go-release-action/blob/master/release.sh#L79 and here https://github.com/wangyoucao577/go-release-action/blob/master/release.sh#L81).

I think an easy fix for this is to add the bash option shopt -s dotglob at the top of the release script.

Could not resolve Host : Null

+ curl --fail -X POST --data-binary @kinto-v1.9-linux-386.tar.gz -H 'Content-Type: application/gzip' -H 'Authorization: Bearer ***' 'null?name=kinto-v1.9-linux-386.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
##[error]The operation was canceled

Getting this error when trying to build a binary files with ldflags enabled.

How to include multiple binaries in one .zip file ?

Hallo,

We have the following project structure:

β”œβ”€β”€ cmd
β”‚   β”œβ”€β”€ first
β”‚   β”‚   β”œβ”€β”€ first.go
β”‚   β”œβ”€β”€ second
β”‚   β”‚   β”œβ”€β”€ second.go

and want to pack the "first" and "second" binaries in one .zip file.
Calling the action multiple times will generate files for each binary.

on:
  release:
    types: [created]

jobs:
  release-linux-amd64:
    name: release linux/amd64
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: linux
        goarch: amd64
        project_path: ./cmd/first
        binary_name: first
   - uses: wangyoucao577/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: linux
        goarch: amd64
        project_path: ./cmd/second
        binary_name: second

Bug: dl.google.com appears to be down or moved breaking this action

Hi all,

It would seem that go-release-action cannot complete setup-go.sh properly since the CDN which it uses to download golang from Google is down/moved.

I could not find anything online relating to the issue, but the following is the error in my pipeline and it seems pretty clear to me:

+ source /setup-go.sh
+++ curl 'https://go.dev/VERSION?m=text'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100     8  100     8    0     0     46      0 --:--:-- --:--:-- --:--:--    46
++ GO_LINUX_PACKAGE_URL=https://dl.google.com/go/go1.[18](https://github.com/SystemFiles/GOG/runs/5996655736?check_suite_focus=true#step:6:18).1.linux-amd64.tar.gz
++ [[ '' == \1\.\1\7 ]]
++ [[ '' == \1\.\1\6 ]]
++ [[ '' == \1\.\1\5 ]]
++ [[ '' == \1\.\1\4 ]]
++ [[ '' == \1\.\1\3 ]]
++ [[ '' == http* ]]
++ wget --progress=dot:mega https://dl.google.com/go/go1.18.1.linux-amd64.tar.gz -O go-linux.tar.gz
--2022-04-12 [19](https://github.com/SystemFiles/GOG/runs/5996655736?check_suite_focus=true#step:6:19):53:03--  https://dl.google.com/go/go1.18.1.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 142.251.45.14, 2607:f8b0:4004:832::[20](https://github.com/SystemFiles/GOG/runs/5996655736?check_suite_focus=true#step:6:20)0e
Connecting to dl.google.com (dl.google.com)|142.251.45.14|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
20[22](https://github.com/SystemFiles/GOG/runs/5996655736?check_suite_focus=true#step:6:22)-04-12 19:53:03 ERROR 404: Not Found.

I suggest we move the base download CDN from dl.google.com to https://go.dev/dl/

What do we think about this?

pre_command can not support multiple commands

E.g.,

pre_command: "apt-get update && apt-get install --no-install-recommends -y gcc-mingw-w64-x86-64 && export CGO_ENABLED=1 "

will result error

+ '[' '!' -z 'apt-get update && apt-get install --no-install-recommends -y gcc-mingw-w64-x86-64 && export CGO_ENABLED=1 ' ']'
+ apt-get update '&&' apt-get install --no-install-recommends -y gcc-mingw-w64-x86-64 '&&' export CGO_ENABLED=1
E: The update command takes no arguments

More details refer to seaweedfs/seaweedfs#1856 (comment)

github-assets-uploader fails with 404

Hi,

I am trying to setup your go-release-action, with no success so far.

I initially tried using it on a private repo. The output seems to show everything builds ok, but then github-assets-uploader gets a 404 when it attempts to use the GitHub API to get a list of the repo's release tags. I then tried using a private access token, via a secret, instead of using the default ${{ secrets.GITHUB_TOKEN }}, but that also gives a 404, and the Action fails. (The permissions I have set for the access token are: repo, workflow, write:packages)

I then tried it on a public repo, assuming my previous issues/experience to be something to do with it being a private repo. But I am still encountering the same problem.

Here is the result of a run using the default GITHUB_TOKEN:
https://github.com/jimsmart/grobotstxt/actions/runs/767392532
Here is the result of a run using a private access token:
https://github.com/jimsmart/grobotstxt/actions/runs/767484813
β€” although they are both failing identically.

Direct link to one of the failures:
https://github.com/jimsmart/grobotstxt/runs/2391628287?check_suite_focus=true#step:4:204

The task fails at the same point, with the same 404, for the private repo also.

I have tried this with go-release-action v1.16 and the pre-release of v1.17

My release.yml

name: release

# on:
#   release:
#     types: [created]

on:
  push:
    tags:
      - "*"
      # - "v**"

jobs:
  releases-matrix:
    name: Release Go binary
    runs-on: ubuntu-latest
    strategy:
      matrix:
        goos: [linux, windows, darwin, freebsd]
        goarch: ["386", amd64]
        exclude:
          - goarch: "386"
            goos: darwin

    steps:
      - uses: actions/checkout@v2
      # - uses: wangyoucao577/[email protected]
      - uses: wangyoucao577/[email protected]
        with:
          # github_token: ${{ secrets.GITHUB_TOKEN }}
          github_token: ${{ secrets.ACTION_TOKEN }}
          goos: ${{ matrix.goos }}
          goarch: ${{ matrix.goarch }}
          project_path: "./cmd/icanhasrobot"
          binary_name: "icanhasrobot"
          extra_files: LICENSE README.md

β€” Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.