name: Windows Portmaster Core DLL

on:
  push:
    paths:
      - 'windows_core_dll/**'
    branches:
      - main
      - development
      - v1-legacy
      - v1-legacy-develop

  pull_request:
    paths:
      - 'windows_core_dll/**'
    branches:
      - main
      - development
      - v1-legacy
      - v1-legacy-develop

  workflow_dispatch:

jobs:
  build:
    name: Build
    runs-on: windows-latest
    steps:
    - name: Checkout Repository
      uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
    - name: Add msbuild to PATH
      uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
    - name: Build DLL
      run: msbuild windows_core_dll\windows_core_dll.sln -t:rebuild -property:Configuration=Release
    - name: Verify DLL
      shell: powershell
      run: |
        if (!(Test-Path "windows_core_dll/x64/Release/portmaster-core.dll")) {
          Write-Error "DLL build failed: portmaster-core.dll not found"
          exit 1
        }
    - name: Upload artifacts
      uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
      with:
        name: portmaster-core-dll
        path: windows_core_dll/x64/Release/portmaster-core.dll
