fix(ci): use target-specific OpenSSL env vars for ARM64 cross-compile #28
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build hanzo-node binaries | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| jobs: | |
| build-binaries: | |
| name: Build binary | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux | |
| - arch: x86_64-unknown-linux-gnu | |
| os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| - arch: aarch64-unknown-linux-gnu | |
| os: ubuntu-22.04 | |
| target: aarch64-unknown-linux-gnu | |
| cross: true | |
| # macOS | |
| - arch: aarch64-apple-darwin | |
| os: macos-14 | |
| target: aarch64-apple-darwin | |
| - arch: x86_64-apple-darwin | |
| os: macos-14 | |
| target: x86_64-apple-darwin | |
| cross_mac: true | |
| # Windows | |
| - arch: x86_64-pc-windows-msvc | |
| os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Configure rust-lld linker for Windows | |
| if: matrix.os == 'windows-2022' | |
| run: | | |
| if (-Not (Test-Path ".cargo")) { mkdir .cargo } | |
| echo '[target.x86_64-pc-windows-msvc]' > .cargo/config.toml | |
| echo 'linker = "rust-lld"' >> .cargo/config.toml | |
| - name: Install protobuf compiler (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y protobuf-compiler | |
| - name: Install cross-compilation tools (Linux ARM64) | |
| if: matrix.cross == true | |
| run: | | |
| sudo dpkg --add-architecture arm64 | |
| # Add arm64 package sources | |
| sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list | |
| echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/arm64.list | |
| echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64.list | |
| echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64.list | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libssl-dev:arm64 pkg-config | |
| rustup target add aarch64-unknown-linux-gnu | |
| - name: Install protobuf compiler (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install protobuf | |
| - name: Install cross-compilation target (macOS x64) | |
| if: matrix.cross_mac == true | |
| run: rustup target add x86_64-apple-darwin | |
| - name: Cache cargo assets | |
| id: cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ matrix.arch }}-build-cargo-v2 | |
| restore-keys: | | |
| ${{ matrix.arch }}-build-cargo- | |
| - name: Configure cross-compilation (Linux ARM64) | |
| if: matrix.cross == true | |
| run: | | |
| mkdir -p .cargo | |
| echo '' >> .cargo/config.toml | |
| echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml | |
| echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml | |
| - name: Build | |
| shell: bash | |
| env: | |
| AI_MODEL_CATALOG_BUILD: 1 | |
| run: | | |
| if [ "${{ matrix.cross }}" = "true" ]; then | |
| export PKG_CONFIG_ALLOW_CROSS=1 | |
| export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu | |
| export AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu | |
| export AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include/aarch64-linux-gnu | |
| export AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_NO_VENDOR=1 | |
| fi | |
| cargo build --release --bin hanzo-node --target ${{ matrix.target }} | |
| - name: Move binary to expected location | |
| shell: bash | |
| run: | | |
| mkdir -p target/release | |
| if [ -f "target/${{ matrix.target }}/release/hanzo-node${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }}" ]; then | |
| cp "target/${{ matrix.target }}/release/hanzo-node${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }}" target/release/ | |
| fi | |
| - name: Prepare bundle files | |
| env: | |
| ZIP_FILE_NAME: ${{ github.ref_name }}.zip | |
| EXTENSION: ${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }} | |
| run: | | |
| mkdir files-to-r2 | |
| cp target/release/hanzo-node${{ env.EXTENSION }} files-to-r2/hanzo-node${{ env.EXTENSION }} | |
| cp -r target/release/hanzo-tools-runner-resources files-to-r2/ | |
| cd ./files-to-r2 | |
| 7z a -tzip ${{ env.ZIP_FILE_NAME}} . -sdel | |
| cp ${{ env.ZIP_FILE_NAME}} latest.zip | |
| - name: Upload bundle to R2 bucket | |
| continue-on-error: true | |
| uses: shallwefootball/s3-upload-action@master | |
| with: | |
| endpoint: https://94a3e3f299092abb1feda2a7481ea845.r2.cloudflarestorage.com | |
| aws_key_id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| aws_secret_access_key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| aws_bucket: hanzoai | |
| source_dir: files-to-r2 | |
| destination_dir: ./hanzo-node/binaries/production/${{ matrix.arch }}/ | |
| - name: Upload bundle to release | |
| uses: svenstaro/upload-release-action@v2 | |
| env: | |
| EXTENSION: ${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }} | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: files-to-r2/${{ github.ref_name }}.zip | |
| asset_name: hanzo-node-${{ matrix.arch }}.zip | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| build-docker-image: | |
| name: Build and push Docker image to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download tools from store to pre-install folder | |
| run: | | |
| ./scripts/update_tools.sh | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile | |
| push: true | |
| build-args: | | |
| BUILD_TYPE=release | |
| AI_MODEL_CATALOG_BUILD=1 | |
| tags: | | |
| hanzoai/hanzo-node:${{ github.ref_name }} | |
| hanzoai/hanzo-node:release-latest |