Skip to content
Merged
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
136 changes: 56 additions & 80 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,108 +11,84 @@ permissions:
contents: write

jobs:
# signls needs cgo for gomidi's rtmidi driver, so each platform is built on a
# matching native runner. GoReleaser only compiles the targets selected by the
# GR_TARGET env var (see .goreleaser.yaml).
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
include:
- target: linux-amd64
os: ubuntu-latest
- target: linux-arm64
os: ubuntu-24.04-arm
- target: darwin
os: macos-latest
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 1
steps:
- uses: actions/checkout@v4

- name: Install Alsa headers
run: sudo apt-get install libasound2-dev
if: startsWith(matrix.os, 'ubuntu')
- uses: actions/checkout@v6
with:
fetch-depth: 0 # full history & tags for version/changelog

- name: Install Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: 1.23

- name: Release version number
run: echo '${{ github.ref_name}}' > VERSION
if: ${{ github.ref_type == 'tag' }}

- name: Development version number
run: echo 'dev-${{ github.sha}}' > VERSION
if: ${{ github.ref_type == 'branch' }}

- name: Build linux|mac
run: go build -o bin/signls && chmod +x bin/signls
if: ${{ !startsWith(matrix.os, 'windows') }}

- name: Build windows
run: go build -ldflags "-linkmode 'external' -extldflags '-static'" -o bin/signls.exe
if: startsWith(matrix.os, 'windows')

- name: Tar.gz linux|mac files
run: tar -zcvf signls_${{ github.ref_name }}_${{ runner.os}}.tar.gz LICENSE -C bin signls
if: ${{ !startsWith(matrix.os, 'windows') }}
go-version: "1.23"

- name: Zip windows files
shell: pwsh
- name: Install ALSA headers
if: startsWith(matrix.target, 'linux')
run: |
Compress-Archive bin\signls.exe signls_${{ github.ref_name }}_${{ runner.os}}.zip
if: ${{ startsWith(matrix.os, 'windows') }}
sudo apt-get update
sudo apt-get install -y libasound2-dev

- name: Upload linux|mac artifact
uses: actions/upload-artifact@v4
with:
name: signls_${{ github.sha }}_${{ runner.os}}
path: signls_${{ github.ref_name }}_${{ runner.os}}.tar.gz
if-no-files-found: error
if: ${{ !startsWith(matrix.os, 'windows') }}
- name: Install Windows cross toolchain (mingw-w64)
if: matrix.target == 'linux-amd64'
run: sudo apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64

- name: Upload windows artifact
uses: actions/upload-artifact@v4
- name: Run GoReleaser (release on tags, snapshot otherwise)
uses: goreleaser/goreleaser-action@v7
with:
name: signls_${{ github.sha }}_${{ runner.os}}
path: signls_${{ github.ref_name }}_${{ runner.os}}.zip
version: "~> v2"
args: >-
${{ startsWith(github.ref, 'refs/tags/v')
&& 'release --clean'
|| 'release --snapshot --clean' }}
env:
GR_TARGET: ${{ matrix.target }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload dist artifacts
uses: actions/upload-artifact@v7
with:
name: dist-${{ matrix.target }}
path: |
dist/*.tar.gz
dist/*.zip
dist/checksums_*.txt
if-no-files-found: error
if: ${{ startsWith(matrix.os, 'windows') }}

# On tags, collect every runner's archives and publish a single release.
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4.1.7
- name: Download all dist artifacts
uses: actions/download-artifact@v8
with:
name: signls_${{ github.sha }}_macOS
path: dist
pattern: dist-*
merge-multiple: true

- uses: actions/download-artifact@v4.1.7
with:
name: signls_${{ github.sha }}_Linux
- name: Combine checksums
run: cat dist/checksums_*.txt > dist/checksums.txt

- uses: actions/download-artifact@v4.1.7
with:
name: signls_${{ github.sha }}_Windows

- name: Create release
uses: softprops/action-gh-release@v1
- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
files: |
signls_*.tar.gz
signls_*.zip

# itchio-release:
# needs: release
# if: startsWith(github.ref, 'refs/tags/v')
# runs-on: ubuntu-latest
# strategy:
# matrix:
# os: [Linux, macOS, Windows]
# env:
# itchio_project: "emprcl/signls"
# steps:
# - uses: actions/download-artifact@v4.1.7
# with:
# name: signls_${{ github.sha }}_${{ matrix.os }}
# - uses: robpc/itchio-upload-action@v1
# with:
# path: signls_${{ github.sha }}_${{ matrix.os }}
# project: ${{ env.itchio_project }}
# channel: ${{ matrix.os }}
# version: ${{ github.ref_name}}
# api-key: ${{ secrets.ITCHIO_API_KEY }}
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
10 changes: 7 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ jobs:
name: checks
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version: 1.23
- uses: actions/checkout@v4
- name: Install ALSA headers
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev
- uses: actions/checkout@v6
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v9
with:
args: -c .golangci.yml
only-new-issues: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin
dist
.coverage
*.json
*.log
29 changes: 24 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
version: "2"
run:
go: "1.23"
linters:
enable:
- thelper
- gofumpt
- tparallel
- unconvert
- unparam

linters-settings:
gofumpt:
module-path: signls
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofumpt
settings:
gofumpt:
module-path: signls
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
94 changes: 94 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: 2

project_name: signls

before:
hooks:
- go mod download

# signls needs cgo: gomidi's rtmidi driver wraps C/C++ (ALSA on Linux, CoreMIDI
# on macOS, WinMM on Windows), so unlike a pure-Go project it can't be
# cross-compiled from a single runner. Each build below is gated by the
# GR_TARGET env var so a given CI runner only compiles the targets its toolchain
# supports (see .github/workflows/build.yml); the runners' dist outputs are then
# collected and published together as one GitHub release.
builds:
# Built natively on the linux-amd64 runner.
- id: linux-amd64
binary: signls
main: .
flags: [-trimpath]
ldflags:
- -s -w -X main.version={{ .Version }}
env:
- CGO_ENABLED=1
goos: [linux]
goarch: [amd64]
skip: '{{ ne (index .Env "GR_TARGET") "linux-amd64" }}'

# Built natively on the linux-arm64 runner (covers 64-bit Raspberry Pi OS).
- id: linux-arm64
binary: signls
main: .
flags: [-trimpath]
ldflags:
- -s -w -X main.version={{ .Version }}
env:
- CGO_ENABLED=1
goos: [linux]
goarch: [arm64]
skip: '{{ ne (index .Env "GR_TARGET") "linux-arm64" }}'

# Cross-compiled from the linux-amd64 runner with the mingw-w64 toolchain.
- id: windows-amd64
binary: signls
main: .
flags: [-trimpath]
ldflags:
- -s -w -X main.version={{ .Version }} -extldflags=-static
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos: [windows]
goarch: [amd64]
skip: '{{ ne (index .Env "GR_TARGET") "linux-amd64" }}'

# Both arches built on the macOS runner (native clang cross-compiles them).
- id: darwin
binary: signls
main: .
flags: [-trimpath]
ldflags:
- -s -w -X main.version={{ .Version }}
env:
- CGO_ENABLED=1
goos: [darwin]
goarch: [amd64, arm64]
skip: '{{ ne (index .Env "GR_TARGET") "darwin" }}'

archives:
- id: signls
# e.g. signls_1.2.3_linux_arm64.tar.gz, signls_1.2.3_windows_amd64.zip
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}
formats: [tar.gz]
format_overrides:
- goos: windows
formats: [zip]
files:
- LICENSE
- README.md

checksum:
# Each runner writes its own checksum file; the release workflow concatenates
# them into a single checksums.txt.
name_template: 'checksums_{{ index .Env "GR_TARGET" }}.txt'

snapshot:
version_template: "{{ incpatch .Version }}-next"

release:
# The GitHub release is assembled by the workflow once every runner's archives
# are collected, so goreleaser itself must not publish.
disable: true
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ GOLANG_BUILD_OPTS += GOOS=$(GOLANG_OS)
GOLANG_BUILD_OPTS += GOARCH=$(GOLANG_ARCH)
GOLANG_BUILD_OPTS += CGO_ENABLED=$(CGO_ENABLED)
GOLANG_LINT := $(BIN)/golangci-lint
GORELEASER := github.com/goreleaser/goreleaser/v2@latest
ASEQDUMP_BIN := aseqdump -p 14:0 | ts '[%H:%M:%.S]'
ASEQDUMP_NO_CLOCK_OPTS := | grep -v Clock

# GR_TARGET selects which goreleaser builds run (see .goreleaser.yaml). Default
# to the host so `make snapshot` builds a local binary.
HOST_OS := $(shell go env GOOS)
HOST_ARCH := $(shell go env GOARCH)
ifeq ($(HOST_OS),darwin)
GR_TARGET ?= darwin
else
GR_TARGET ?= $(HOST_OS)-$(HOST_ARCH)
endif

$(BIN):
mkdir -p $(BIN)

Expand All @@ -21,6 +32,10 @@ build: $(BIN)
$(GOLANG_BUILD_OPTS) $(GOLANG_BIN) build -o $(BIN)/$(BIN_NAME)
chmod +x $(BIN)/$(BIN_NAME)

# Build a local release snapshot (archives in dist/) for the host target.
snapshot:
GR_TARGET=$(GR_TARGET) $(GOLANG_BIN) run $(GORELEASER) release --snapshot --clean

checks: $(GOLANG_LINT)
$(GOLANG_LINT) run ./...

Expand Down
Loading
Loading