Skip to content

Commit

Permalink
Add cross-compilation Github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Jan 22, 2024
1 parent 85edfb6 commit 5f964e6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ concurrency:
cancel-in-progress: true

jobs:
cross_build:
name: Cross-platform builds
strategy:
matrix:
go-version: ['1.21.x']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Cross-compile
run: ./cross-compile.sh

build_and_test:
name: Build and test
strategy:
Expand Down
30 changes: 30 additions & 0 deletions cross-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -eu

GO="go"
if [ -v GOROOT ];
then
GO="$GOROOT/bin/go"
fi

function buildem() {
for GOOS in $1
do
for GOARCH in $2
do
echo "Building $GOOS/$GOARCH..."
GOOS=$GOOS GOARCH=$GOARCH $GO build ./...
done
done
}

GOARCHES="386 amd64 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le"
buildem "linux" "$GOARCHES"

GOARCHES="386 amd64 arm arm64"
GOOSES="freebsd" # TBD netbsd openbsd windows
buildem "$GOOSES" "$GOARCHES"

GOARCHES_DARWIN="arm64 amd64"
buildem "darwin" "$GOARCHES_DARWIN"

0 comments on commit 5f964e6

Please sign in to comment.