# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: LANCommander

on:
  push:
    paths:
      - 'LANCommander/**'
      - 'LANCommander.PCGamingWiki/**'
      - 'LANCommander.SDK/**'
  pull_request:
    paths:
      - 'LANCommander/**'
      - 'LANCommander.PCGamingWiki/**'
      - 'LANCommander.SDK/**'
  workflow_dispatch:

jobs:
  build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Setup Node.js environment
      uses: actions/setup-node@v3.8.1
    - run: cd LANCommander/wwwroot/scripts; npm install
    - name: Build
      run: dotnet build "./LANCommander/LANCommander.csproj" --no-restore
    - name: Publish
      run: dotnet publish "./LANCommander/LANCommander.csproj" -c Release -o _Build --self-contained --os win -p:PublishSingleFile=true
    - name: Sign Windows Binary
      uses: nadeemjazmawe/Sign-action-signtool.exe@v0.1
      with:
        certificate: "${{ secrets.CERTIFICATE }}"
        cert-password: "${{ secrets.CERTIFICATE_PASSWORD }}"
        filepath: "./_Build/LANCommander.exe"
    - name: Upload Artifacts
      uses: actions/upload-artifact@v2
      with:
        name: LANCommander
        path: "./_Build"
