Skip to content

Commit

Permalink
Building on Linux arm64 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto authored Jan 8, 2025
1 parent e5b7ead commit 5e61692
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,27 @@ on:
- "docs/**"

jobs:
build-macos:
runs-on: macos-latest
build:
strategy:
matrix:
target:
- arch: amd64
os: linux
runs-on: ubuntu-latest
ext: so
- arch: arm64
os: linux
runs-on: [self-hosted, Linux, ARM64]
ext: so
- arch: arm64
os: macos
runs-on: macos-latest
ext: dylib
- arch: amd64
os: macos
runs-on: macos-latest
ext: dylib
runs-on: ${{ matrix.target.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
Expand All @@ -28,38 +47,15 @@ jobs:
- name: Build
run: |
./build.sh
- name: Archive libgoast library (amd64)
- name: Archive libgoast library (${{ matrix.target.arch }})
uses: actions/upload-artifact@v4
with:
name: libgoast-amd64.dylib
path: libgoast-amd64.dylib
- name: Archive libgoast library (arm64)
uses: actions/upload-artifact@v4
with:
name: libgoast-arm64.dylib
path: libgoast-arm64.dylib
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Build
run: |
./build.sh
- name: Archive libgoast library (amd64)
uses: actions/upload-artifact@v4
with:
name: libgoast-amd64.so
path: libgoast-amd64.so
name: libgoast-${{ matrix.target.arch }}.${{ matrix.target.ext }}
path: libgoast-${{ matrix.target.arch }}.${{ matrix.target.ext }}
publish:
runs-on: ubuntu-latest
needs:
- build-macos
- build-linux
- build
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
steps:
- name: Determine Version
Expand Down Expand Up @@ -89,6 +85,10 @@ jobs:
with:
name: libgoast-amd64.so
path: .
- uses: actions/download-artifact@v4
with:
name: libgoast-arm64.so
path: .
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
Expand Down
23 changes: 19 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#!/bin/bash
ARCH=`uname -s | tr '[:upper:]' '[:lower:]'`
OS=`uname -s | tr '[:upper:]' '[:lower:]'`
ARCH=`arch`

if [ $ARCH == "darwin" ]
if [ $OS == "darwin" ]
then
EXTENSION="dylib"
else
EXTENSION="so"
fi

CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o libgoast-amd64.${EXTENSION} lib.go
echo "Building on $OS for $ARCH"

if [ $ARCH == "darwin" ]
if [ $OS == "darwin" ]
then
CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o libgoast-arm64.${EXTENSION} lib.go
CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o libgoast-amd64.${EXTENSION} lib.go
fi

if [ $OS == "linux" ]
then
if [ $ARCH == "aarch64" ]
then
CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o libgoast-arm64.${EXTENSION} lib.go
fi

if [ $ARCH == "x86_64" ]
then
CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o libgoast-amd64.${EXTENSION} lib.go
fi
fi

0 comments on commit 5e61692

Please sign in to comment.