diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8bc1a7c..cc58f930 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,9 +9,73 @@ permissions: packages: write jobs: + build-binaries: + name: Build and Upload ${{ matrix.target }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + binary: netvisor-daemon-linux-x86_64 + use_cross: false + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + binary: netvisor-daemon-linux-aarch64 + use_cross: true + - os: macos-latest + target: aarch64-apple-darwin + binary: netvisor-daemon-darwin-arm64 + use_cross: false + + defaults: + run: + working-directory: ./backend + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: backend + key: ${{ matrix.target }} + + - name: Install OpenSSL (Linux) + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config + + - name: Install cross + if: matrix.use_cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Build daemon + run: | + if [ "${{ matrix.use_cross }}" = "true" ]; then + cross build --release --bin daemon --target ${{ matrix.target }} + else + cargo build --release --bin daemon --target ${{ matrix.target }} + fi + + - name: Prepare binary + run: | + cp target/${{ matrix.target }}/release/daemon ../${{ matrix.binary }} + chmod +x ../${{ matrix.binary }} + + - name: Upload to release + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.binary }} + build-docker: name: Build and Push Docker Images runs-on: ubuntu-latest + needs: build-binaries steps: - uses: actions/checkout@v4 @@ -77,53 +141,4 @@ jobs: ghcr.io/${{ github.repository }}/daemon:${{ steps.version.outputs.version }} ghcr.io/${{ github.repository }}/daemon:latest cache-from: type=gha - cache-to: type=gha,mode=max - - build-binaries: - name: Build and Upload ${{ matrix.target }} - runs-on: ${{ matrix.os }} - needs: build-docker # Wait for Docker images first - strategy: - matrix: - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - binary: netvisor-daemon-linux-x86_64 - - os: macos-latest - target: aarch64-apple-darwin - binary: netvisor-daemon-darwin-arm64 - - defaults: - run: - working-directory: ./backend - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - workspaces: backend - key: ${{ matrix.target }} - - - name: Install OpenSSL (Linux) - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config - - - name: Build daemon - run: cargo build --release --bin daemon --target ${{ matrix.target }} - - - name: Prepare binary - run: | - cp target/${{ matrix.target }}/release/daemon ../${{ matrix.binary }} - chmod +x ../${{ matrix.binary }} - - - name: Upload to release - uses: softprops/action-gh-release@v2 - with: - files: ${{ matrix.binary }} \ No newline at end of file + cache-to: type=gha,mode=max \ No newline at end of file