Automatically publish Go binaries to Github Release Assets through Github Action.
- Build
Gobinaries for release and publish to Github Release Assets. - Customizable
Goversions.golang 1.14by default. - Support different
Goproject path in repository. - Support multiple binaries in same repository.
- Customizable binary name.
- Support multiple
GOOS/GOARCHbuild in parallel by Github Action Matrix Strategy gracefully. - Publish
.zipinstead of.tar.gzforwindows. - No
musllibrary dependency issue onlinux. - 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).
# .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| Parameter | Mandatory/Optional | Description |
|---|---|---|
| github_token | Mandatory | Your GITHUB_TOKEN for uploading releases to Github asserts. |
| 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, s390x, and so on. |
| goversion | Optional | The 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_path | Optional | Where to run go build. Use . by default. |
| 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_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 |
- Release for multiple OS/ARCH in parallel by matrix strategy.
Gocode is not in.of your repository.- Customize binary name.
- Use
go 1.13.1from downloadable URL instead of default1.14. - Package extra
LICENSEandREADME.mdinto artifacts.
# .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"
extra_files: LICENSE README.md