Skip to content

Commit

Permalink
Build macOS artifacts on a darwin runner
Browse files Browse the repository at this point in the history
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 <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Oct 4, 2021
1 parent bda583b commit 703d9c8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,40 @@ on:
env:
GO111MODULE: on
jobs:
artifacts-darwin:
name: Artifacts Darwin
runs-on: macos-11
timeout-minutes: 20
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Make darwin artifacts
run: make artifacts-darwin
- name: "Upload artifacts"
uses: actions/upload-artifact@v2
with:
name: artifacts-darwin
path: _artifact/
release:
runs-on: ubuntu-20.04
needs: artifacts-darwin
timeout-minutes: 20
steps:
- uses: actions/download-artifact@v2
with:
name: artifacts-darwin
path: _artifact/
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install gcc-aarch64-linux-gnu
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- uses: actions/checkout@v2
- name: "Compile binaries"
run: make artifacts
Expand Down
27 changes: 22 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,34 @@ jobs:
EXAMPLE: ${{ matrix.example }}
run: ./hack/test-example.sh examples/$EXAMPLE

artifacts:
name: Artifacts
# the release pipeline uses Linux, so we Linux here as well
artifacts-darwin:
name: Artifacts Darwin
runs-on: macos-11
timeout-minutes: 20
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Make darwin artifacts
run: make artifacts-darwin

artifacts-linux:
name: Artifacts Linux
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install gcc-aarch64-linux-gnu
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Make artifacts
run: make artifacts
- name: Make linux artifacts
run: make artifacts-linux
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ uninstall:
clean:
rm -rf _output

.PHONY: artifacts
artifacts:
.PHONY: artifacts-darwin
artifacts-darwin:
mkdir -p _artifacts
GOOS=darwin GOARCH=amd64 make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-x86_64.tar.gz ./
GOOS=darwin GOARCH=arm64 make clean binaries
$(TAR) -C _output -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-arm64.tar.gz ./

.PHONY: artifacts-linux
artifacts-linux:
mkdir -p _artifacts
GOOS=linux GOARCH=amd64 make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-x86_64.tar.gz ./
GOOS=linux GOARCH=arm64 make clean binaries
GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-aarch64.tar.gz ./

0 comments on commit 703d9c8

Please sign in to comment.