name: Build

on:
  push:
    branches: [main, dev]
    paths:
      - "**.cs"
      - "**.csproj"
      - "**.sln"
      - "**.xaml"
      - "**.resx"
      - "libs/**"
      - "DeviceTemplates/**"
      - "Resources/**"
  pull_request:
    types: [opened, synchronize, reopened]
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: windows-latest
    # Same-repo non-draft PRs already get a full build from pr-build.yml —
    # skip the duplicate compile. Forks and drafts keep this gate.
    if: >-
      github.event_name != 'pull_request' ||
      github.event.pull_request.head.repo.full_name != github.repository ||
      github.event.pull_request.draft == true

    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Setup .NET SDK
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: |
            8.0.x
            9.0.x

      - name: Restore dependencies
        run: dotnet restore

      - name: Build plugin DLL
        run: dotnet build -c Release --no-restore
