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