name: Create Release With Binary Assets

on:
  push:
    tags:
      - v*

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rid:
          [
            linux-arm64,
            linux-arm,
            linux-musl-arm64,
            linux-musl-arm,
            linux-musl-x64,
            linux-x64,
            win-x64,
          ]
      fail-fast: true
    steps:
      - uses: actions/checkout@v4.2.2

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

      - name: Publish Binaries
        working-directory: src/Server
        run: |
          dotnet publish ./InverterMon.Server.csproj -c Release -r ${{ matrix.rid }} --self-contained -p:PublishTrimmed=true -o ./bin/${{ matrix.rid }}
          rm -rf ./bin/${{ matrix.rid }}/BlazorDebugProxy
          cd ./bin/${{ matrix.rid }}
          zip -r -9 ../${{ matrix.rid }}.zip ./*

      - name: Create Release
        uses: softprops/action-gh-release@v2.2.1
        if: ${{ !contains(github.ref, 'beta') }}
        with:
          draft: false
          name: ${{ github.ref_name }} Release
          body_path: src/changelog.md
          files: src/Server/bin/*.zip