diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc46e721..4d73936c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,3 +18,6 @@ jobs: run: make test - name: Lint run: make lint + - name: Cross build + if: ${{ runner.os == 'Linux' }} + run: make cross diff --git a/Makefile b/Makefile index d37c8cef..c9ba60b7 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ .SHELLFLAGS = -ec PACKAGES ?= mountinfo mount BINDIR ?= _build/bin +CROSS_OSES ?= linux freebsd darwin windows +CROSS_ARCHES ?= amd64 arm arm64 ppc64le s390x +OS_ARCH_SKIP = '^((freebsd|darwin|windows)/(ppc64le|s390x)|windows/arm64|freebsd/s390x)$$' .PHONY: all -all: lint test +all: lint test cross .PHONY: test test: @@ -24,3 +27,15 @@ $(BINDIR)/golangci-lint: $(BINDIR) $(BINDIR): mkdir -p $(BINDIR) + +.PHONY: cross +cross: + for os in $(CROSS_OSES); do \ + for arch in $(CROSS_ARCHES); do \ + echo "$$os/$$arch" | grep -qE $(OS_ARCH_SKIP) && continue; \ + echo "# building for $$os/$$arch"; \ + for p in $(PACKAGES); do \ + (cd $$p && GOOS=$$os GOARCH=$$arch go build .); \ + done; \ + done; \ + done