Add dotnet CI workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build and test the package project | |
name: Bonsai.Mixer | |
on: | |
push: | |
pull_request: | |
env: | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
ContinuousIntegrationBuild: true | |
CiRunNumber: ${{ github.run_number }} | |
CiRunPushSuffix: ${{ github.ref_name }}-ci${{ github.run_number }} | |
CiRunPullSuffix: pull-${{ github.event.number }}-ci${{ github.run_number }} | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
configuration: [debug, release] | |
os: [windows-latest] | |
include: | |
- os: windows-latest | |
configuration: release | |
collect-packages: true | |
name: ${{matrix.os}} ${{matrix.configuration}} | |
runs-on: ${{matrix.os}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration ${{ matrix.configuration }} | |
- name: Test | |
run: dotnet test --no-build --verbosity normal --configuration ${{ matrix.configuration }} | |
- name: Pack | |
id: pack | |
if: matrix.collect-packages | |
env: | |
CiBuildVersionSuffix: ${{ github.event_name == 'push' && env.CiRunPushSuffix || env.CiRunPullSuffix }} | |
run: dotnet pack --no-build --configuration ${{ matrix.configuration }} | |
- name: Collect packages | |
uses: actions/upload-artifact@v4 | |
if: matrix.collect-packages && steps.pack.outcome == 'success' && always() | |
with: | |
name: Packages | |
if-no-files-found: error | |
path: artifacts/package/${{ matrix.configuration }}/** | |
publish-github: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
needs: [build] | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: Packages | |
- name: Push to GitHub Packages | |
run: dotnet nuget push "Packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}} | |
env: | |
# This is a workaround for https://github.com/NuGet/Home/issues/9775 | |
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0 |