name: CI/CD

on:
  push:
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'

jobs:
  build-windows:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v4

    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x

    - name: Restore dependencies
      run: dotnet restore src/Plpext/Plpext.sln

    - name: Install tools
      run: dotnet tool install --global vpk

    - name: Build UI
      run: dotnet build src/Plpext/Plpext.UI/Plpext.UI.csproj --configuration Release --no-restore

    - name: Dotnet publish
      run: dotnet publish src/Plpext/Plpext.UI/Plpext.UI.csproj -c Release -r win-x64 -o publish

    - name: Vpk pack
      run: vpk pack --packAuthors="Felipe Cotti" --packTitle=Plpext -i build/plpext.ico -s docs/plpext.png  --mainExe=Plpext.exe --packId=Plpext --packVersion=${{ github.ref_name }} --packDir=publish -o build/win
    
    - name: Upload artifact
      uses: softprops/action-gh-release@v2
      with:
        draft: false
        prerelease: false
        tag_name: ${{ github.ref_name }}
        name: Release ${{ github.ref_name }}
        files: build/win/Plpext-win-Setup.exe
      env:
        GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}