name: Build

on:
  push:
    branches:
      - 'main'
    paths-ignore:
      - 'docs/**'
      - '*.md'
  pull_request:
    paths-ignore:
      - 'docs/**'
      - '*.md'

jobs:
  build:
    runs-on: ubuntu-latest

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

    - name: Setup .NET 8 SDK
      uses: actions/setup-dotnet@v4
      with:
        global-json-file: ./global.json

    - name: Pack
      run: dotnet pack Vortice.Win32.sln --configuration Release

    - name: Publish to NuGet
      if: github.event_name == 'push'
      run: |
        dotnet nuget push artifacts/package/release/*.nupkg -k ${{secrets.NUGET_TOKEN}} --skip-duplicate --source https://api.nuget.org/v3/index.json
        dotnet nuget push artifacts/package/release/*.snupkg -k ${{secrets.NUGET_TOKEN}} --skip-duplicate --source https://api.nuget.org/v3/index.json
