Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 21 additions & 139 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,90 +16,17 @@ name: Build

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

permissions:
contents: read

jobs:
build-no-console:
name: Build (no console, no CGO)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod

- name: Build without console tag
env:
CGO_ENABLED: "0"
run: go build -o bin/lk ./cmd/lk

- name: Verify binary
run: bin/lk --help > /dev/null

lint-and-test:
cross-build:
name: Cross-build (goreleaser snapshot)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
submodules: true

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod

- name: Static Check
uses: dominikh/staticcheck-action@288b4e28bae83c59f35f73651aeb5cab746a06fc # v1.4.0
with:
version: "latest"
install-go: false

- name: Test
run: go test -v ./...

build:
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
suffix: darwin_arm64
- os: ubuntu-latest
suffix: linux_amd64
zig_target: x86_64-linux-gnu.2.28
alsa_arch: amd64
alsa_triple: x86_64-linux-gnu
- os: ubuntu-latest
suffix: linux_arm64
zig_target: aarch64-linux-gnu.2.28
alsa_arch: arm64
alsa_triple: aarch64-linux-gnu
goarch: arm64
- os: ubuntu-latest
suffix: linux_arm
zig_target: arm-linux-gnueabihf.2.28
alsa_arch: armhf
alsa_triple: arm-linux-gnueabihf
goarch: arm
goarm: "7"
- os: ubuntu-latest
suffix: windows_amd64
zig_target: x86_64-windows-gnu
goos: windows
goarch: amd64
- os: ubuntu-latest
suffix: windows_arm64
zig_target: aarch64-windows-gnu
goos: windows
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
Expand All @@ -111,72 +38,27 @@ jobs:
go-version-file: go.mod

- name: Install Zig
if: matrix.zig_target
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.14.1

- name: Install ALSA headers
if: matrix.alsa_arch
run: |
sudo dpkg --add-architecture ${{ matrix.alsa_arch }}
if [ "${{ matrix.alsa_arch }}" != "amd64" ]; then
CODENAME=$(lsb_release -cs)
# Restrict existing sources to amd64 to avoid 404s for foreign arch
for f in /etc/apt/sources.list.d/*.sources; do
grep -q '^Architectures:' "$f" || sudo sed -i '/^Types:/a Architectures: amd64 i386' "$f"
done
# Add ports.ubuntu.com for the foreign architecture
printf 'Types: deb\nURIs: http://ports.ubuntu.com/ubuntu-ports\nSuites: %s %s-updates\nComponents: main universe\nArchitectures: %s\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
"$CODENAME" "$CODENAME" "${{ matrix.alsa_arch }}" | sudo tee /etc/apt/sources.list.d/ports.sources
fi
sudo apt-get update
sudo apt-get install -y libasound2-dev:${{ matrix.alsa_arch }}
- name: Cache cross-compile inputs
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .cross
key: cross-${{ runner.os }}-zig0.14.1-alsa1.2.12-${{ hashFiles('scripts/setup-cross.sh') }}

- name: Generate Windows import libraries
if: matrix.goos == 'windows' && matrix.zig_target
run: |
ZIG_LIB=$(zig env | jq -r '.lib_dir')
echo "ZIG_LIB=${ZIG_LIB}" >> "$GITHUB_ENV"
LIB_DIR="${ZIG_LIB}/libc/mingw/lib-common"
# Zig bundles MinGW .def files but lld needs .a import libraries.
# Go's compiled objects embed COFF /DEFAULTLIB directives (e.g. dbghelp,
# bcrypt) that lld resolves directly, bypassing Zig's lazy .def→.a
# generation. Pre-generate all import libraries so lld can find them.
MACHINE=${{ matrix.goarch == 'amd64' && 'i386:x86-64' || 'arm64' }}
for def in "${LIB_DIR}"/*.def; do
lib=$(basename "$def" .def)
[ -f "${LIB_DIR}/lib${lib}.a" ] && continue
zig dlltool -d "$def" -l "${LIB_DIR}/lib${lib}.a" -m "$MACHINE" 2>/dev/null || true
done
- name: GoReleaser snapshot build
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7
with:
distribution: goreleaser
version: latest
args: build --snapshot --clean

- name: Build
env:
CGO_ENABLED: ${{ (matrix.goos && !matrix.zig_target) && '0' || '1' }}
CC: ${{ matrix.zig_target && format('zig cc -target {0}', matrix.zig_target) || '' }}
CXX: ${{ matrix.zig_target && format('zig c++ -target {0}', matrix.zig_target) || '' }}
# Zig uses its own sysroot; point it at the system ALSA headers and libraries
CGO_CFLAGS: ${{ matrix.alsa_triple && format('-isystem /usr/include -isystem /usr/include/{0}', matrix.alsa_triple) || '' }}
CGO_LDFLAGS: ${{ matrix.alsa_triple && format('-L/usr/lib/{0}', matrix.alsa_triple) || '' }}
# -fms-extensions: enable __try/__except (SEH) used by WebRTC
# -DNTDDI_VERSION: target Windows 10 base to skip WinRT includes absent from MinGW
CGO_CXXFLAGS: ${{ matrix.goos == 'windows' && '-fms-extensions -DNTDDI_VERSION=0x0A000000' || '' }}
GOOS: ${{ matrix.goos || '' }}
GOARCH: ${{ matrix.goarch || '' }}
GOARM: ${{ matrix.goarm || '' }}
shell: bash
- name: Verify native binary runs
run: |
EXT=""; if [ "${GOOS:-}" = "windows" ]; then EXT=".exe"; fi
TAGS=""
if [ "$CGO_ENABLED" = "1" ]; then TAGS="-tags console"; fi
# Force external linking for Windows so Go uses zig cc (CC) as the linker,
# and add Zig's MinGW lib path so lld can find the generated import libraries.
EXTLD=""
if [ "${GOOS:-}" = "windows" ] && [ "$CGO_ENABLED" = "1" ]; then
EXTLD="-linkmode=external -extldflags '-L${ZIG_LIB}/libc/mingw/lib-common'"
fi
go build $TAGS -ldflags "-w -s $EXTLD" -o "bin/lk${EXT}" ./cmd/lk

- name: Verify binary
if: "!matrix.goos && !matrix.goarch"
run: bin/lk --help > /dev/null
# Pick the linux-amd64 binary out of dist/ and run --help.
binary=$(find dist -type f -name lk -path '*linux*amd64*' | head -n1)
test -n "$binary" || { echo "no linux/amd64 binary in dist/"; exit 1; }
# Static-libgcc/libstdc++ binary should run on glibc 2.28+ Ubuntu runners.
"$binary" --help > /dev/null
68 changes: 0 additions & 68 deletions .github/workflows/docker.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:

permissions:
contents: write
packages: write

# workflow tasks
jobs:
Expand Down Expand Up @@ -83,6 +84,29 @@ jobs:
with:
go-version-file: go.mod

- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.14.1

- name: Cache cross-compile inputs
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .cross
key: cross-${{ runner.os }}-zig0.14.1-alsa1.2.12-${{ hashFiles('scripts/setup-cross.sh') }}

- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3

- name: Login to DockerHub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install ALSA headers (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
Expand All @@ -41,6 +45,18 @@ jobs:
set -euo pipefail
go test -race -json -v ./... 2>&1 | tee test.log

- name: Verify fish_autocomplete is up to date
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
go build -o /tmp/lk ./cmd/lk
/tmp/lk generate-fish-completion -o /tmp/fish_autocomplete.fresh
if ! diff -u autocomplete/fish_autocomplete /tmp/fish_autocomplete.fresh; then
echo "::error::autocomplete/fish_autocomplete is stale; regenerate with:"
echo " go build -o /tmp/lk ./cmd/lk && /tmp/lk generate-fish-completion -o autocomplete/fish_autocomplete"
exit 1
fi

- name: Upload test log
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
if: always()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
bin/
.idea/
dist/
.cross/

# Local artifacts
.task/
Expand Down
Loading
Loading