feat: create dotnet.yml

This commit is contained in:
tux
2025-07-05 07:28:00 +05:30
committed by GitHub
parent 335f58a60c
commit db7094987b

79
.github/workflows/dotnet-desktop.yml vendored Normal file
View File

@@ -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 }}