A personal github action to build and package Go projects.
name:
- description: The name of the project or binary to be produced
- required: true
path:
- description: Path to the golang project (relative to the repository root).
- required: true
- default: current working directory
dest:
- description: Directory where the built files will be placed.
- required: false
- default: ./dist/
ldflags:
- description: Value to -ldflags build option.
- required: false
- default: -s -w
flags:
- description: Flags to pass to 'go build' command
- required: false
- default: ""
checksum:
- description: A file to contain checksums for all binaries.
- required: false
- default: checksums.txt
includeVersion:
- description: Whether or not to add the current tag or commit in release name.
- required: false
- default: false
The built binaries are located under the output directory.
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
# checkout repository
- uses: actions/checkout@v4
# setup go
- uses: actions/setup-go@v5
with:
go-version: ">=1.24.0" # the go version to install and use
# ...
# build with go
- name: Build and package binaries
uses: henryhale/gopack@v1.0.3
with:
path: "./my-go-project"
dest: "./dist"
ldflags: "-s -w -X 'main.version=$(git describe --tags)'"
flags: "-trimpath"
checksum: "checksums.txt"
Released under MIT License.
© 2025 - present Henry Hale