vox_engine 0.3.0

voxel game engine
name: Build

on:
  push:
    branches: ["**"]

jobs:
  build:
    name: Build (${{ matrix.name }})
    runs-on: ${{ matrix.os }}
    env:
      CMAKE_POLICY_VERSION_MINIMUM: "3.5"
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: linux-x86_64
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            ext: ""
          - name: windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            ext: ".exe"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Cmake 3.31
        uses: jwlawson/actions-setup-cmake@v2
        with:
          cmake-version: "3.31.x"

      - name: Install Rust Toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Install linux dependencies
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            ninja-build pkg-config python3 \
            libasound2-dev libpulse-dev libudev-dev libdbus-1-dev \
            libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev \
            libxfixes-dev libxss-dev libxtst-dev libxkbcommon-dev \
            libwayland-dev wayland-protocols libdecor-0-dev \
            libdrm-dev libgbm-dev libgl1-mesa-dev libegl1-mesa-dev \
            libvulkan-dev
            
      - name: Linux compiler workaround
        if: runner.os == 'Linux'
        run: echo "CXXFLAGS=-include cstdint" >> "$GITHUB_ENV"

      - name: Windows CMake setup
        if: runner.os == 'Windows'
        shell: bash
        run: |
          choco install ninja -y --no-progress
          echo "CMAKE_GENERATOR=Ninja" >> "$GITHUB_ENV"

      - name: Build
        run: cargo build --release --target ${{ matrix.target }} --features sdl3/build-from-source-static



      - name: Collect Binaries
        shell: bash
        run: |
          mkdir -p dist

          for f in target/${{ matrix.target }}/release/*${{ matrix.ext }}; do
            if [ -f "$f" ] && { [ "${{ matrix.ext }}" = ".exe" ] || [ -x "$f" ]; }; then
              cp "$f" dist/
            fi
          done
          cp -r textures dist/textures
          ls -laR dist

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.name }}-$${{ github.ref_name }}
          path: dist/*
          if-no-files-found: error