Skip to content

Commit 11ba276

Browse files
committed
Build macOS artifacts on a darwin runner
Cross-compiling from amd64 to arm64 with CGO_ENABLED=1 seems to only work when GOOS is the same between compile host and target. Signed-off-by: Jan Dubois <[email protected]>
1 parent 1cd3aa6 commit 11ba276

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,40 @@ on:
1010
env:
1111
GO111MODULE: on
1212
jobs:
13+
artifacts-darwin:
14+
name: Artifacts Darwin
15+
runs-on: macos-11
16+
timeout-minutes: 20
17+
steps:
18+
- uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.17.x
21+
- uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 1
24+
- name: Make darwin artifacts
25+
run: make artifacts-darwin
26+
- name: "Upload artifacts"
27+
uses: actions/upload-artifact@v2
28+
with:
29+
name: artifacts-darwin
30+
path: _artifact/
1331
release:
1432
runs-on: ubuntu-20.04
33+
needs: artifacts-darwin
1534
timeout-minutes: 20
1635
steps:
36+
- uses: actions/download-artifact@v2
37+
with:
38+
name: artifacts-darwin
39+
path: _artifact/
1740
- uses: actions/setup-go@v2
1841
with:
1942
go-version: 1.17.x
43+
- name: Install gcc-aarch64-linux-gnu
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y gcc-aarch64-linux-gnu
2047
- uses: actions/checkout@v2
2148
- name: "Compile binaries"
2249
run: make artifacts

.github/workflows/test.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,34 @@ jobs:
167167
EXAMPLE: ${{ matrix.example }}
168168
run: ./hack/test-example.sh examples/$EXAMPLE
169169

170-
artifacts:
171-
name: Artifacts
172-
# the release pipeline uses Linux, so we Linux here as well
170+
artifacts-darwin:
171+
name: Artifacts Darwin
172+
runs-on: macos-11
173+
timeout-minutes: 20
174+
steps:
175+
- uses: actions/setup-go@v2
176+
with:
177+
go-version: 1.17.x
178+
- uses: actions/checkout@v2
179+
with:
180+
fetch-depth: 1
181+
- name: Make darwin artifacts
182+
run: make artifacts-darwin
183+
184+
artifacts-linux:
185+
name: Artifacts Linux
173186
runs-on: ubuntu-20.04
174187
timeout-minutes: 20
175188
steps:
176189
- uses: actions/setup-go@v2
177190
with:
178191
go-version: 1.17.x
192+
- name: Install gcc-aarch64-linux-gnu
193+
run: |
194+
sudo apt-get update
195+
sudo apt-get install -y gcc-aarch64-linux-gnu
179196
- uses: actions/checkout@v2
180197
with:
181198
fetch-depth: 1
182-
- name: Make artifacts
183-
run: make artifacts
199+
- name: Make linux artifacts
200+
run: make artifacts-linux

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ uninstall:
7373
clean:
7474
rm -rf _output
7575

76-
.PHONY: artifacts
77-
artifacts:
76+
.PHONY: artifacts-darwin
77+
artifacts-darwin:
7878
mkdir -p _artifacts
7979
GOOS=darwin GOARCH=amd64 make clean binaries
8080
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-x86_64.tar.gz ./
8181
GOOS=darwin GOARCH=arm64 make clean binaries
8282
$(TAR) -C _output -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-arm64.tar.gz ./
83+
84+
.PHONY: artifacts-linux
85+
artifacts-linux:
86+
mkdir -p _artifacts
8387
GOOS=linux GOARCH=amd64 make clean binaries
8488
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-x86_64.tar.gz ./
85-
GOOS=linux GOARCH=arm64 make clean binaries
89+
GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc make clean binaries
8690
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-aarch64.tar.gz ./

0 commit comments

Comments
 (0)