Skip to content

Build

Build #2

Workflow file for this run

name: Build
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
env:
GO_VERSION: '1.26.1'
jobs:
# ─── Test on the native host ─────────────────────────────────────────
# Cgo cross-compile is brittle, so we run unit tests once on Linux and
# rely on the matrix below for the actual cross-platform builds.
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Install audio + GUI dev headers
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1-mesa-dev xorg-dev libxxf86vm-dev \
libasound2-dev portaudio19-dev pkg-config
- name: go vet
run: go vet ./...
- name: go test
run: go test ./...
# ─── Cross-platform builds ───────────────────────────────────────────
# Each runner builds natively for its own OS — no cross-toolchains.
# macOS gets two passes for amd64 and arm64.
build:
needs: test
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
runs-on: ubuntu-24.04
goos: linux
goarch: amd64
artifact: boom-linux-amd64
- name: linux-arm64
runs-on: ubuntu-24.04-arm
goos: linux
goarch: arm64
artifact: boom-linux-arm64
- name: darwin-amd64
runs-on: macos-13 # last Intel runner
goos: darwin
goarch: amd64
artifact: boom-darwin-amd64
- name: darwin-arm64
runs-on: macos-14 # Apple silicon
goos: darwin
goarch: arm64
artifact: boom-darwin-arm64
- name: windows-amd64
runs-on: windows-2022
goos: windows
goarch: amd64
artifact: boom-windows-amd64.exe
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
# ── Linux: apt for fyne/GLFW + portaudio dev package ─────────────
- name: Install Linux build deps
if: matrix.goos == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1-mesa-dev xorg-dev libxxf86vm-dev \
libasound2-dev portaudio19-dev pkg-config
# ── macOS: brew for portaudio + pkg-config ───────────────────────
- name: Install macOS build deps
if: matrix.goos == 'darwin'
run: |
brew update
brew install portaudio pkg-config
# ── Windows: msys2 ships mingw-w64 *and* portaudio + pkg-config
# in one package, which is far less painful than chocolatey or
# vcpkg for cgo. Subsequent steps that need the toolchain run
# under `shell: msys2 {0}`.
- name: Set up msys2 with portaudio
if: matrix.goos == 'windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-portaudio
mingw-w64-x86_64-pkgconf
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
# ── Build (linux/darwin) ─────────────────────────────────────────
- name: Build
if: matrix.goos != 'windows'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: '1'
run: |
mkdir -p build
go build -ldflags "-s -w" -o build/${{ matrix.artifact }} ./cmd/boom
# ── Build (windows, under msys2 so the cgo toolchain is found) ──
- name: Build (windows)
if: matrix.goos == 'windows'
shell: msys2 {0}
env:
GOOS: windows
GOARCH: amd64
CGO_ENABLED: '1'
run: |
export PATH="/mingw64/bin:$PATH"
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig"
mkdir -p build
go build -ldflags "-s -w" -o build/${{ matrix.artifact }} ./cmd/boom
# Bundle libportaudio + its mingw runtime deps next to the
# exe. Windows looks in the executable's directory before PATH,
# so the user just unzips and double-clicks.
cp /mingw64/bin/libportaudio.dll build/ 2>/dev/null || \
cp /mingw64/bin/libportaudio-2.dll build/
cp /mingw64/bin/libwinpthread-1.dll build/ 2>/dev/null || true
cp /mingw64/bin/libgcc_s_seh-1.dll build/ 2>/dev/null || true
cp /mingw64/bin/libstdc++-6.dll build/ 2>/dev/null || true
# macOS / linux upload only the raw binary; users on those platforms
# either build the proper packaged bundle locally with `make
# package-*` (which runs scripts/bundle-portaudio-darwin.sh) or
# already have libportaudio installed via their package manager.
- name: Upload artifact (single binary)
if: matrix.goos != 'windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: build/${{ matrix.artifact }}
if-no-files-found: error
retention-days: 14
# Windows: upload the whole build/ dir so libportaudio.dll travels
# with the exe.
- name: Upload artifact (windows bundle)
if: matrix.goos == 'windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: build/
if-no-files-found: error
retention-days: 14