name: ci

env:
  PROJECT_NAME: JitBuddy

on:
  push:
    paths-ignore:
    - 'doc/**'
    - 'img/**'
    - 'changelog.md'
    - 'readme.md'
  pull_request:

jobs:
  build:
    runs-on: windows-latest

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

    - name: Install .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.0.100

    - name: Build & test (Release)
      run: dotnet test src -c Release

    - name: Pack
      run: dotnet pack src -c Release

    - name: Publish
      if: github.event_name == 'push'
      run: |      
          if ( "${{github.ref}}" -match "^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$" ) {
              dotnet nuget push src\${{env. PROJECT_NAME}}\bin\Release\*.nupkg -s nuget.org -k ${{secrets. NUGET_TOKEN}}
          } else {
              echo "publish is only enabled by tagging with a release tag"
          }
