Build Workflow¶
The build.yml workflow verifies cross-platform build compatibility.
Usage¶
Default Platforms¶
| Platform | Runner | Architecture |
|---|---|---|
| Linux | ubuntu-latest | x64 |
| macOS | macos-latest | ARM64 |
| Windows | windows-latest | x64 |
Inputs¶
| Input | Type | Default | Description |
|---|---|---|---|
go-version | string | '1.24' | Go version |
go-version-file | string | '' | Path to go.mod |
working-directory | string | '.' | Code directory |
platforms | string | 'ubuntu-latest,macos-latest,windows-latest' | Platforms |
build-flags | string | '-v' | Build flags |
upload-artifacts | boolean | false | Upload binaries |
Examples¶
Single Platform¶
jobs:
build:
uses: go-gamma/actions/.github/workflows/build.yml@v1
with:
go-version: '1.24'
platforms: 'ubuntu-latest'
Linux Only¶
jobs:
build:
uses: go-gamma/actions/.github/workflows/build.yml@v1
with:
go-version: '1.24'
platforms: 'ubuntu-latest,ubuntu-22.04'
With Artifacts¶
jobs:
build:
uses: go-gamma/actions/.github/workflows/build.yml@v1
with:
go-version: '1.24'
upload-artifacts: true
Artifacts are named: {module}-{OS}-{arch}
Custom Build Flags¶
jobs:
build:
uses: go-gamma/actions/.github/workflows/build.yml@v1
with:
go-version: '1.24'
build-flags: '-v -ldflags="-s -w"'
Library Projects¶
For libraries without a main package:
jobs:
build:
uses: go-gamma/actions/.github/workflows/build.yml@v1
with:
go-version: '1.24'
upload-artifacts: false # No binary to upload
The workflow still verifies the code compiles on all platforms.
Platform-Specific Issues¶
Common cross-platform issues caught:
| Issue | Description |
|---|---|
| Path separators | / vs \ handling |
| Line endings | CRLF vs LF |
| Case sensitivity | Filename casing |
| CGO dependencies | C library availability |
| syscall usage | OS-specific system calls |
CGO
CGO is disabled by default (CGO_ENABLED=0). If you need CGO, consider using the release workflow with cross-compilation.