Skip to content

Commit

Permalink
aarch64 support with macos-13-xlarge, buildjet arm linux runner (#40)
Browse files Browse the repository at this point in the history
they all need money to run it, close #8
  • Loading branch information
timzaak authored Oct 5, 2023
1 parent ac599a6 commit 14ccb13
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/client_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
#-
# name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -29,7 +23,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: build and push docker image
uses: docker/build-push-action@v2
Expand All @@ -52,7 +46,10 @@ jobs:
build: make release-linux
- host: macos-latest
target: x86_64-apple-darwin
build: make release-mac-x86_64
build: make release-mac-x86_64
- host: macos-13-xlarge
target: aarch64-apple-darwin
build: make release-mac-aarch64
# - host: macos-latest # This needs aarch64 OpenSSL, will wait github action support MacOS M1(https://github.com/github/roadmap/issues/528), then run this.
# target: aarch64-apple-darwin
# build: make release-mac-aarch64
Expand Down Expand Up @@ -87,6 +84,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: fornet-${{ matrix.settings.target }}
path: release/*
if-no-files-found: error
WindowsCommandLine:
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/client_build_arm64.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
name: fornet arm64 client build
# run at self-hosted mac min M2
# But it does not success for SSL timeout. we may try other methods to do this
on:
workflow_dispatch:
inputs:
version:
required: true
description: "version to release"
description: "docker version to release"
env:
REGISTRY: ghcr.io
jobs:
docker-and-linux:
runs-on: self-hosted
docker:
runs-on: buildjet-2vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v3
with:
submodules: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
#uses: crazy-max/ghaction-setup-docker@v2
uses: docker/setup-buildx-action@v3
-
name: Login to GithubPackages
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: timzaak
password: ${{ secrets.DOCKERHUB_BUILDJET_TOKEN }}
-
name: build and push docker image
uses: docker/build-push-action@v2
with:
context: .
#platforms: linux/amd64,linux/arm64
platforms: linux/arm64
push: true
file: command/docker/client/client.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{env.REGISTRY}}/fornetcode/fornet:lastet
cache-to: type=inline
tags: ${{ env.REGISTRY }}/fornetcode/fornet:${{github.event.inputs.version}}
- name: copy binary from docker to release directory
run: |
mkdir -p release
docker run --rm -v ./release:/release ${{ env.REGISTRY }}/fornetcode/fornet:${{github.event.inputs.version}} cp /bin/fornet:/release/ && cp /bin/fornet-cli:/release
cd release && tar -czvf release/fornet-linux-aarch64.tar.gz ./fornet ./fornet-cli && rm fornet && rm fornet-cli
docker run --rm -v ./release:/release ${{ env.REGISTRY }}/fornetcode/fornet:${{github.event.inputs.version}} cp /usr/bin/fornet /release/ && cp /usr/bin/fornet-cli /release
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: fornet-linux-aarch64.tar.gz
path: release/fornet-linux-aarch64.tar.gz
if-no-files-found: error

mac:
name: fornet-aarch64-unknown-linux-gnu
path: release/*
if-no-files-found: error
command:
strategy:
max-parallel: 1
fail-fast: true
matrix:
settings:
- host: self-hosted
target: aarch64-apple-darwin
build: make release-mac-aarch64

- host: buildjet-2vcpu-ubuntu-2204-arm
target: aarch64-unknown-linux-gnu
build: make release-linux-aarch64
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
Expand All @@ -72,7 +75,7 @@ jobs:
target: ${{ matrix.settings.target }}
profile: minimal
- name: Set up cargo cache
uses: actions/cache@v3
uses: buildjet/cache@v3
continue-on-error: false
with:
path: |
Expand All @@ -91,5 +94,6 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: fornet-${{ matrix.settings.target }}
path: release/*
if-no-files-found: error
25 changes: 15 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ release-mac-x86_64:
otool -L client/target/x86_64-apple-darwin/release/fornet
strip client/target/x86_64-apple-darwin/release/fornet-cli
otool -L client/target/x86_64-apple-darwin/release/fornet-cli
tar -C client/target/x86_64-apple-darwin/release/ -czvf release/fornet-mac-x86_64.tar.gz ./fornet ./fornet-cli
cp client/target/x86_64-apple-darwin/release/fornet ./release/
cp client/target/x86_64-apple-darwin/release/fornet-cli ./release/

# brew install wget
release-mac-aarch64:
Expand All @@ -25,28 +26,32 @@ release-mac-aarch64:
strip client/target/aarch64-apple-darwin/release/fornet
otool -L client/target/aarch64-apple-darwin/release/fornet
strip client/target/aarch64-apple-darwin/release/fornet-cli
otool -L client/target/aarch64-apple-darwin/release/fornet-cli
tar -C client/target/aarch64-apple-darwin/release/ -czvf release/fornet-mac-aarch64.tar.gz ./fornet ./fornet-cli
otool -L client/target/aarch64-apple-darwin/release/fornet-cli
cp client/target/aarch64-apple-darwin/release/fornet ./release/
cp client/target/aarch64-apple-darwin/release/fornet-cli ./release/

# This is for self-hosted arm64-linux
release-linux-aarch64:
cd client && cargo build --release
mkdir protoc && cd protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-aarch64.zip && unzip protoc-21.9-linux-aarch64.zip && sudo cp bin/protoc /usr/bin
cp -r protoc/include/* protobuf/
sudo apt-get install -y build-essential
mkdir release
cd client && cargo build --release --target=aarch64-unknown-linux-gnu
strip client/target/aarch64-unknown-linux-gnu/release/fornet
strip client/target/aarch64-unknown-linux-gnu/release/fornet-cli
tar -C client/target/aarch64-unknown-linux-gnu/release/ -czvf release/fornet-linux-x86_64.tar.gz ./fornet ./fornet-cli

cp client/target/aarch64-unknown-linux-gnu/release/fornet ./release/
cp client/target/aarch64-unknown-linux-gnu/release/fornet-cli ./release/


release-linux:
mkdir protoc && cd protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-x86_64.zip && unzip protoc-21.9-linux-x86_64.zip && sudo cp bin/protoc /usr/bin
cp -r protoc/include/* protobuf/
sudo apt-get install -y build-essential
mkdir release
mkdir release
cd client && cargo build --release --target=x86_64-unknown-linux-gnu
strip client/target/x86_64-unknown-linux-gnu/release/fornet
strip client/target/x86_64-unknown-linux-gnu/release/fornet-cli
tar -C client/target/x86_64-unknown-linux-gnu/release/ -czvf release/fornet-linux-x86_64.tar.gz ./fornet ./fornet-cli

cp client/target/x86_64-unknown-linux-gnu/release/fornet ./release
cp client/target/x86_64-unknown-linux-gnu/release/fornet-cli ./release

release-backend:
cd admin-web && npm ci && npm run build:prod && cd ../
Expand Down

0 comments on commit 14ccb13

Please sign in to comment.