Sign inSign up

wangyoucao577/go-release-action

By wangyoucao577

•Updated 9 months ago

Automatically publish Go binaries to Github Release Assets through Github Action.

Image
0

7.7K

wangyoucao577/go-release-action repository overview

⁠Go Release GitHub Action

Build Docker
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. golang 1.14 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 instead of .tar.gz for windows.
  • 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.).

⁠Usage

⁠Basic Example
# .github/workflows/release.yaml

on: 
  release:
    types: [created]

jobs:
  release-linux-amd64:
    name: release linux/amd64
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: wangyoucao577/go-release-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        goos: linux
        goarch: amd64
⁠Parameters
ParameterMandatory/OptionalDescription
github_tokenMandatoryYour GITHUB_TOKEN for uploading releases to Github asserts.
goosMandatoryGOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
goarchMandatoryGOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
goversionOptionalThe Go compiler version. 1.14 by default, optional 1.13.
It also takes download URL instead of version string if you'd like to use more specified version. But make sure your URL is linux-amd64 package, better to find the URL from Go - Downloads⁠.
E.g., https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz.
project_pathOptionalWhere to run go build.
Use . by default.
binary_nameOptionalSpecify another binary name if do not want to use repository basename.
Use your repository's basename if not set.
pre_commandOptionalExtra 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_flagsOptionalAdditional arguments to pass the go build command.
ldflagsOptionalValues to provide to the -ldflags argument.
⁠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 default 1.14.
# .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, windows/386, windows/amd64, darwin/386, darwin/amd64 
        goos: [linux, windows, darwin]
        goarch: ["386", amd64]
    steps:
    - uses: actions/checkout@v2
    - uses: wangyoucao577/go-release-action@master
      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"
⁠More Examples

Tag summary

Content type

Image

Digest

sha256:109206eb3…

Size

146.1 MB

Last updated

9 months ago

docker pull wangyoucao577/go-release-action