name: CMake

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v3

    - name: Use GitHub Actions provided vcpkg
      shell: pwsh
      run: Add-Content "$env:GITHUB_ENV" "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT"

    - name: Configure CMake
      shell: pwsh
      run: cmake "--preset=ci-$("${{matrix.os}}".split("-")[0])"
        -D CMAKE_BUILD_TYPE=Release

    - name: Build
      run: cmake --build build --config Release

    - name: Install
      run: |
        cmake --install build --prefix prefix --config Release --component Printer
        cmake --install build --prefix prefix --config Release --component Development

    - name: Test
      working-directory: build
      run: ctest -C Release
