Go Multi-Platform Build
ActionsBuild Go binaries for multiple platforms, package them, and output file list
v0.1.0
LatestBy chihqiang
This GitHub Action builds Go binaries for multiple platforms, packages them into .zip or .tar.gz files, and outputs a list of generated archive files.
- Supports building for Windows, linux, macOS on amd64 and arm64 architectures
- Injects version info into the binary
- Supports including additional files or directories in the package
- Generates SHA256 and MD5 checksum files
- Outputs a space-separated list of created archive files for downstream steps
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
bin_name |
Binary name, defaults to repo name | string | - | no |
main_go |
Go main file or package path | string | main.go |
no |
version |
Version string, defaults to GitHub ref | string | ${GITHUB_REF} |
no |
add_files |
Extra files/directories (space separated) | string | "" | no |
dist_root_path |
Output directory | string | dist |
no |
name: Build and Package Go Binaries
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Run Go Multi-Platform Build Action
id: build
uses: chihqiang/gobuild-action@main
with:
bin_name: myapp
main_go: main.go
version: ${{ github.ref_name }}
add_files: |
README.md
LICENSE
dist_root_path: dist
- name: List generated files
run: echo "Built archive files: ${{ env.GOBUILD_FILES }}"
| env Name | Description |
|---|---|
GOBUILD_FILES |
Space-separated list of generated archive file paths (e.g. dist/myapp_linux_amd64.tar.gz dist/myapp_windows_amd64.zip) |
Feel free to open issues or PRs to improve this multi-platform Go build action!
Go Multi-Platform Build is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.