name: macOS CI

on:
  workflow_dispatch:
  push:
    branches: [ "master", "devel" ]
  pull_request:
    branches: [ "master", "devel" ]

env:
  BUILD_TYPE: RelWithDebInfo
  INSTALL_LOCATION: ${{github.workspace}}/SonivoxV3
  TEMP: ${{github.workspace}}/temp/

jobs:
  build:
    runs-on: macos-latest
    name: macOS CI

    steps:
    - uses: actions/checkout@v4

    - name: Temp Environment Variable
      run: |
        mkdir -p ${{github.workspace}}/temp

    - name: Configure CMake
      run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_LOCATION}}

    - name: Build
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

    - name: Test
      working-directory: ${{github.workspace}}/build
      run: ctest -C ${{env.BUILD_TYPE}} --verbose

    - name: Install
      run: cmake --install ${{github.workspace}}/build

    - name: Create Archive
      run: |
        cd ${{github.workspace}}
        tar cvf SonivoxV3.tar SonivoxV3

    - name: Upload Artifacts
      uses: actions/upload-artifact@v4
      with:
        name: SonivoxV3-macos
        path: SonivoxV3.tar
        retention-days: 90
        overwrite: true
