name: CI

on:
  push:
    paths:
      - '**'
  pull_request:
    paths:
      - '**'

permissions:
  contents: read

jobs:
  build-linux:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@main
    - name: Build
      run: sudo apt update && sudo apt install -q -y libx11-dev libfreetype6 libfreetype6-dev libxft-dev libxft2 && cd build && make tests -j2

  build-windows-x86:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@main
    - name: Build
      run: sudo apt update && sudo apt install -q -y mingw-w64 && cd build && make TARGET=mingw32 -j2
    - name: Package
      run: cd build && ./windowscreatezip.sh _x86 HXCSOFT
    - uses: actions/upload-artifact@main
      with:
        name: hxcfloppyemulator-winx86-${{ github.sha }}
        path: build/HxCFloppyEmulator_Software_win_x86.zip

  build-hxcdiskbrowser-windows-x86:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@main
    - name: Build
      run: sudo apt update && sudo apt install -q -y mingw-w64 && cd build && make TARGET=mingw32 STANDALONEFSBROWSER_BUILD=1 -j2
    - name: Package
      run: cd build && ./windowscreatezip.sh _x86 DOSDISKBROWSER
    - uses: actions/upload-artifact@main
      with:
        name: hxcfloppyemulator-dosdiskbrowser-winx86-${{ github.sha }}
        path: build/HxCFloppyEmulator_DosDiskBrowser_win_x86.zip

  build-windows-x64:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@main
    - name: Build
      run: sudo apt update && sudo apt install -q -y mingw-w64 && cd build && make TARGET=mingw64 -j2
    - name: Package
      run: cd build && ./windowscreatezip.sh _x64 HXCSOFT
    - uses: actions/upload-artifact@main
      with:
        name: hxcfloppyemulator-winx64-${{ github.sha }}
        path: build/HxCFloppyEmulator_Software_win_x64.zip
