From 14ccb13eeb35474c18e8806db682451bbb81de82 Mon Sep 17 00:00:00 2001 From: timzaak Date: Thu, 5 Oct 2023 21:36:03 +0800 Subject: [PATCH] aarch64 support with macos-13-xlarge, buildjet arm linux runner (#40) they all need money to run it, close #8 --- .github/workflows/client_build.yml | 14 ++++---- .github/workflows/client_build_arm64.yml | 44 +++++++++++++----------- Makefile | 25 ++++++++------ 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/.github/workflows/client_build.yml b/.github/workflows/client_build.yml index 5461964..fba1a38 100644 --- a/.github/workflows/client_build.yml +++ b/.github/workflows/client_build.yml @@ -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 @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/client_build_arm64.yml b/.github/workflows/client_build_arm64.yml index 06296e8..8b452ae 100644 --- a/.github/workflows/client_build_arm64.yml +++ b/.github/workflows/client_build_arm64.yml @@ -1,24 +1,23 @@ 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 @@ -26,40 +25,44 @@ jobs: 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 @@ -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: | @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index 9602970..03d9a2c 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 ../