name: Build

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

env:
  DOTNET_CLI_TELEMETRY_OPTOUT: false

jobs:
  build:
    runs-on: windows-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        submodules: recursive

    - name: Install .NET 7.0.x
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 7.0.x
        include-prerelease: true

    - name: Pack
      run: dotnet pack Vortice.Win32.sln --configuration Release --output build/packages

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