From db7094987b7043a4023b046e103e059460177b03 Mon Sep 17 00:00:00 2001 From: tux Date: Sat, 5 Jul 2025 07:28:00 +0530 Subject: [PATCH] feat: create dotnet.yml --- .github/workflows/dotnet-desktop.yml | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/dotnet-desktop.yml diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml new file mode 100644 index 0000000..2ebae8e --- /dev/null +++ b/.github/workflows/dotnet-desktop.yml @@ -0,0 +1,79 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [ published ] + +jobs: + build: + strategy: + matrix: + os: [windows-latest, macos-latest] + include: + - os: windows-latest + runtime: win-x64 + artifact-name: windows-x64 + - os: macos-latest + runtime: osx-arm64 + artifact-name: macos-arm64 + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore --configuration Release + + - name: Publish + if: github.event_name == 'release' + run: | + dotnet publish \ + --configuration Release \ + --runtime ${{ matrix.runtime }} \ + --self-contained true \ + --output ./publish/${{ matrix.artifact-name }} + + - name: Upload build artifacts + if: github.event_name == 'release' + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.artifact-name }} + path: ./publish/${{ matrix.artifact-name }} + + create-release: + needs: build + runs-on: ubuntu-latest + if: github.event_name == 'release' + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v3 + with: + path: ./artifacts + + - name: Create release archives + run: | + cd ./artifacts + for dir in */; do + zip -r "${dir%/}.zip" "$dir" + done + + - name: Upload release assets + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/*.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}