From bc552b382a80cd3392f98866e06b098dc39c0935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michel?= Date: Tue, 12 Dec 2023 10:27:40 +0000 Subject: [PATCH] handle ARM64 for linux and darwin builds and releases --- .github/workflows/build-release.yml | 6 ++++++ .github/workflows/build.yml | 16 ++++++++++------ .goreleaser-linux.yml | 14 +++++++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index a71ca33..ee012d9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -30,6 +30,12 @@ jobs: uses: actions/setup-go@v4 with: go-version: '1.21.x' + - + name: Install toolchain for compiling ARM + run: sudo apt-get -y install gcc-aarch64-linux-gnu + - + name: Install lcrypt for arm64 + run: sudo dpkg --add-architecture arm64 && sudo apt update && sudo apt-get -y install libcrypt-dev:arm64 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a55709..7ee97ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,29 +9,33 @@ jobs: matrix: go-version: [ '1.20.x', '1.21.x' ] goos: [linux] - goarch: [amd64] + archparams: [{goarch: amd64, cc: gcc},{goarch: arm64, cc: aarch64-linux-gnu-gcc}] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install toolchain for compiling ARM + run: sudo apt-get -y install gcc-aarch64-linux-gnu + - name: Install lcrypt for arm64 + run: sudo dpkg --add-architecture arm64 && sudo apt update && sudo apt-get -y install libcrypt-dev:arm64 - name: Setup Go uses: actions/setup-go@v4 with: go-version: '${{matrix.go-version}}' - - name: Install dependencies + - name: Install Go dependencies run: go get ./... - name: Build Client - run: env CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.goarch}} go build -v client/main.go + run: env CC=${{matrix.archparams.cc}} CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.archparams.goarch}} go build -v client/main.go - name: Build Server - run: env CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.goarch}} go build -v server/main.go + run: env CC=${{matrix.archparams.cc}} CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.archparams.goarch}} go build -v server/main.go - name: Test with the Go CLI - run: env CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.goarch}} go run github.com/onsi/ginkgo/v2/ginkgo -r + run: env CC=${{matrix.archparams.cc}} CGO_ENABLED=1 GOOS=${{matrix.goos}} GOARCH=${{matrix.archparams.goarch}} go run github.com/onsi/ginkgo/v2/ginkgo -r build-macos: strategy: matrix: go-version: [ '1.20.x', '1.21.x' ] goos: [darwin] - goarch: [amd64] + goarch: [amd64,arm64] runs-on: macos-latest steps: - uses: actions/checkout@v4 diff --git a/.goreleaser-linux.yml b/.goreleaser-linux.yml index 0d681ec..1fb4d48 100644 --- a/.goreleaser-linux.yml +++ b/.goreleaser-linux.yml @@ -26,6 +26,12 @@ builds: - linux goarch: - amd64 + - arm64 + overrides: + - goos: linux + goarch: arm64 + env: + - CC=aarch64-linux-gnu-gcc - id: "ssh3-server" main: ./server/main.go @@ -36,7 +42,13 @@ builds: - linux goarch: - amd64 - + - arm64 + overrides: + - goos: linux + goarch: arm64 + env: + - CC=aarch64-linux-gnu-gcc + archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of `uname`.