name: build
on:
  push:
    branches:
      - master
jobs:
  build-linux:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@master
        with:
          submodules: recursive
      - name: Install dependencies
        run: |
          sudo add-apt-repository universe
          sudo apt-get update -qq
          sudo apt-get install -y build-essential libgtk-3-dev libsdl2-dev git ninja-build nlohmann-json3-dev libfmt-dev
          sudo apt-get install -y vulkan-tools libvulkan1 libvulkan-dev vulkan-validationlayers-dev spirv-tools
          
          git clone --recursive https://github.com/mandreyel/mio
          cd mio
          cmake -B build -DBUILD_TESTING=False -DCMAKE_BUILD_TYPE=Release
          cd build
          sudo make install
      - name: Build Kaizen
        run: |
          cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
          cmake --build build --config Release
      - name: Collect artifacts
        run: |
          mkdir upload
          cp -r build/{kaizen,resources} upload
      - name: Upload artifacts
        uses: actions/upload-artifact@master
        with:
          name: kaizen-linux
          path: upload
          if-no-files-found: error
  build-windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@master
        with:
          submodules: recursive
      - name: Setup dependencies
        run: |
          vcpkg install sdl2[vulkan]:x64-windows fmt:x64-windows nlohmann-json:x64-windows mio:x64-windows
      - name: Build Kaizen
        run: |
          cmake -B build -T clangcl -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
          cmake --build build --config Release
      - name: Collect artifacts
        run: |
          mkdir upload
          cp build/Release/kaizen.exe upload
          mkdir upload/resources
          cp build/resources/* upload/resources
          cp build/Release/SDL2.dll upload
          cp build/Release/fmt.dll upload
      - name: Upload artifacts
        uses: actions/upload-artifact@master
        with:
          name: kaizen-windows
          path: upload
          if-no-files-found: error