@vmvarela/semantic-release-build-go
v0.1.0
Published
Build Go binaries for multiple targets during semantic-release
Readme
@vmvarela/semantic-release-build-go
Build Go binaries for multiple OS/architecture targets during a semantic-release pipeline.
Install
npm install --save-dev @vmvarela/semantic-release-build-goRequires Node.js >= 24 and Go >= 1.21.
Usage
Add the plugin to your .releaserc.yml:
plugins:
- '@semantic-release/commit-analyzer'
- '@semantic-release/release-notes-generator'
- '@vmvarela/semantic-release-build-go'
- '@semantic-release/github'Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| targets | { goos, goarch, asset, ext? }[] | — | List of build targets. Each entry defines a GOOS/GOARCH pair and the output asset name. |
| go_version | string | — | Required Go version string (e.g. "1.22"). Used for verification only. |
| ldflags | string | -s -w -X main.version=<version> | Custom linker flags. If omitted, the release version is injected via -X main.version. |
Target format
Each target object:
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| goos | string | yes | Target OS (e.g. linux, darwin, windows) |
| goarch | string | yes | Target arch (e.g. amd64, arm64) |
| asset | string | yes | Output filename (without extension) |
| ext | string | no | File extension (e.g. .exe for Windows) |
Example
plugins:
- '@vmvarela/semantic-release-build-go':
go_version: '1.22'
targets:
- goos: linux
goarch: amd64
asset: my-cli-linux-amd64
- goos: darwin
goarch: amd64
asset: my-cli-darwin-amd64
- goos: darwin
goarch: arm64
asset: my-cli-darwin-arm64
- goos: windows
goarch: amd64
asset: my-cli-windows-amd64
ext: .exe
ldflags: -s -w -X main.version=1.0.0API
verifyConditions
Validates the plugin configuration using the shared BuildGoConfigSchema.
Checks that go is available on PATH and prints the installed version.
prepare
Cross-compiles each target with CGO_ENABLED=0.
Output is written to dist/<asset><ext>. Returns a PrepareResult with artifact metadata.
Requirements
- Node.js >= 24
- Go >= 1.21 (matching
go_version) - semantic-release >= 24
License
MIT
