Build, test and release with cargo: CI, release workflow, cross-build and packaging scripts, Homebrew

This commit is contained in:
Andy Dixon
2026-10-08 19:54:56 +01:00
parent 507f635b49
commit ce8acf0ade
14 changed files with 335 additions and 118 deletions
+26 -17
View File
@@ -4,29 +4,38 @@ on:
pull_request:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- run: rustup component add rustfmt clippy
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets -- -D warnings
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-15-intel, windows-2025]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: format
if: runner.os == 'Linux'
run: test -z "$(gofmt -l .)"
- run: go vet ./...
- run: go test ./...
- name: race
if: runner.os != 'Windows'
run: go test -race ./...
- name: cross-build
if: runner.os == 'Linux'
- uses: actions/checkout@v5
- run: cargo test --release --locked --all-targets
- run: cargo run --release --locked -- --no-ui .
cross:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/cross-tools
- name: every target but macOS (built natively by the test job)
run: TARGETS="linux/amd64 linux/arm64 linux/386 linux/arm linux/riscv64 windows/amd64 windows/arm64 freebsd/amd64 netbsd/amd64" scripts/build.sh
- name: static binaries run under qemu
run: |
for t in linux/arm64 linux/386 darwin/arm64 windows/amd64 freebsd/amd64; do
GOOS=${t%/*} GOARCH=${t#*/} CGO_ENABLED=0 go build -o /dev/null ./cmd/mapsize
sudo apt-get update -q && sudo apt-get install -yq qemu-user
for t in "arm64 qemu-aarch64" "arm qemu-arm" "riscv64 qemu-riscv64"; do
${t#* } dist/mapsize-linux-${t%% *} --no-ui src >/dev/null
done