name: Publish

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

env:
  SOLUTION_FILE_PATH: ./minty.sln
  BUILD_CONFIGURATION: Release

permissions:
  contents: read

jobs:
  build:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
      with:
        submodules: recursive

    - name: Install MSBuild
      uses: microsoft/setup-msbuild@v1.0.2

    - name: Build minty solution
      working-directory: ./
      run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}

    - name: Removing unused files
      shell: bash
      run: |
        rm -rf ./x64/Release/*.obj
        rm -rf ./x64/Release/*.pdb
      
    - name: Install 7zip
      run: choco install 7zip

    - name: Compress files to 7z
      run: |
        $date = Get-Date -Format "yyyyMMddHHmmss"
        7z a minty-release-$date.7z ./x64/Release/*
    - name: Upload minty latest artifact
      uses: actions/upload-artifact@v3.1.0
      with:
        name: minty-release
        path: ./minty-release-*.7z
        if-no-files-found: error
