# .github/workflows/release.yml

on:
  release:
    types: [created]

env:
  PROJECT_NAME: Needlework.Net
  ASSEMBLY_NAME: NeedleworkDotNet

jobs:
  build:
    runs-on: windows-latest  # For a list of available runner types, refer to
                             # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
    steps:
    - name: Install .NET Core
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 8.0.x
    - name: Checkout
      uses: actions/checkout@v4
    - name: Build
      run: dotnet build ${{env.PROJECT_NAME}} -c Release
    - name: Publish
      run: dotnet publish ${{env.PROJECT_NAME}} -c Release -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false -o publish -r win-x64 --self-contained=false
    - name: Zip files
      run: 7z a -tzip ${{env.ASSEMBLY_NAME}}-win-x64.zip ./Publish/* README.md LICENSE
    - name: Upload to release
      uses: softprops/action-gh-release@v1
      if: ${{startsWith(github.ref, 'refs/tags/') }}
      with:
          files: ${{env.ASSEMBLY_NAME}}-win-x64.zip