Skip to content

Commit 28cb73e

Browse files
committed
fix multi-arch builds
1 parent 9f0c8d3 commit 28cb73e

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

.github/workflows/go.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ jobs:
113113
- uses: extractions/setup-just@v4
114114

115115
- name: Generate build files (${{ matrix.goarch }})
116-
env:
117-
CC: ${{ matrix.cc }}
118-
GOOS: linux
119-
GOARCH: ${{ matrix.goarch }}
120116
run: |
121117
OUTPUT_BIN="dist/zfs-file-history-linux-${{ matrix.goarch }}"
122-
just OUTPUT_BIN="${OUTPUT_BIN}" ${{ matrix.just_target }}
118+
119+
# Pass cross-compilation variables explicitly as arguments to just
120+
just \
121+
GOOS="linux" \
122+
GOARCH="${{ matrix.goarch }}" \
123+
CC="${{ matrix.cc }}" \
124+
OUTPUT_BIN="${OUTPUT_BIN}" \
125+
${{ matrix.just_target }}
126+
123127
file "${OUTPUT_BIN}"
124128
125129
- name: Upload artifacts

Justfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Explicitly define variables so they accept command-line/matrix overrides
2+
GOOS := "linux"
3+
GOARCH := "amd64"
4+
CC := "gcc"
5+
CGO_ENABLED := "1"
6+
17
GO_FLAGS := ""
28
NAME := "zfs-file-history"
39
OUTPUT_BIN := "bin/" + NAME
@@ -21,9 +27,11 @@ coverage-html:
2127
go test -coverprofile=coverage.out ./...
2228
go tool cover -html=coverage.out
2329

24-
# Builds the CLI
30+
# Builds the CLI with explicit architecture/compiler environment variables
2531
build:
26-
@go build {{GO_FLAGS}} \
32+
@mkdir -p $(dirname {{OUTPUT_BIN}})
33+
CGO_ENABLED={{CGO_ENABLED}} GOOS={{GOOS}} GOARCH={{GOARCH}} CC={{CC}} \
34+
go build {{GO_FLAGS}} \
2735
-ldflags "-w -s \
2836
-X {{NAME}}/cmd/global.Version={{VERSION}} \
2937
-X {{PACKAGE}}/cmd/global.Version={{VERSION}} \
@@ -43,6 +51,7 @@ run: build
4351

4452
# Deploy to custom bin directory
4553
deploy-custom: clean build
54+
mkdir -p ~/.custom/bin/
4655
cp ./{{OUTPUT_BIN}} ~/.custom/bin/
4756

4857
# Deploy to /usr/local/bin

0 commit comments

Comments
 (0)