name: .NET # This workflow should trigger in the following cases: # - The commit is any push in any branch in the repo # - The commit is a published PR from anyone else # # This setup is done to avoid duplicate runs for the same exact commits, for cases when # the PR is done from a branch in this repo, which would already trigger the "push" # condition. This way, only PRs from forks will actually trigger the workflow. # # Because we can't really check these conditions from the global triggers here, they are # added to the two root jobs below instead. If canceled, the whole workflow will stop. on: [push, pull_request] env: EXCLUDE_RUN_ID_FROM_PACKAGE: false EXCLUDE_SUFFIX_FROM_VERSION: false jobs: # Build the whole ComputeSharp solution build-solution: if: >- github.event_name == 'push' || github.event.pull_request.user.login != github.repository_owner strategy: matrix: configuration: [Debug, Release] platform: [x64, arm64] runs-on: windows-2022 steps: - name: Git checkout uses: actions/checkout@v4 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 - name: Build run: msbuild /restore -t:build /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} /bl - name: Upload MSBuild binary log uses: actions/upload-artifact@v4 with: name: msbuild_log_${{matrix.configuration}}_${{matrix.platform}} path: msbuild.binlog if-no-files-found: error # Pack all projects with dotnet/MSBuild to generate NuGet packages. # This workflow also uploads the resulting packages as artifacts. build-packages: if: >- github.event_name == 'push' || github.event.pull_request.user.login != github.repository_owner runs-on: windows-2022 steps: - name: Git checkout uses: actions/checkout@v4 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 - name: Build ComputeSharp.Core package run: dotnet pack src\ComputeSharp.Core\ComputeSharp.Core.csproj -c Release - name: Build ComputeSharp package run: dotnet pack src\ComputeSharp\ComputeSharp.csproj -c Release - name: Build ComputeSharp.Dxc package run: dotnet pack src\ComputeSharp.Dxc\ComputeSharp.Dxc.csproj -c Release - name: Build ComputeSharp.D3D12MemoryAllocator package run: dotnet pack src\ComputeSharp.D3D12MemoryAllocator\ComputeSharp.D3D12MemoryAllocator.csproj -c Release # Upload the packages to the pipeline artifacts - name: Upload package artifacts uses: actions/upload-artifact@v4 with: name: nuget_packages path: artifacts\*.nupkg if-no-files-found: error # Run all unit tests referencing the ComputeSharp projects directly run-tests: needs: [build-solution] runs-on: windows-2022 # Set the environment variable which is then looked up in ComputeSharp.Dxc. # This is a workaround for https://github.com/actions/runner-images/issues/6531. env: CI_RUNNER_DOTNET_TEST_PLATFORM: x64 steps: - name: Git checkout uses: actions/checkout@v4 # DirectX 12 unit tests - name: Run ComputeSharp.Tests run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release /p:Platform=x64 -v n -l "console;verbosity=detailed" - name: Run ComputeSharp.Tests.Internals run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release /p:Platform=x64 -v n -l "console;verbosity=detailed" # Run all unit tests using D3D12MA run-tests-d3d12ma: needs: [build-solution] runs-on: windows-2022 env: CI_RUNNER_DOTNET_TEST_PLATFORM: x64 steps: - name: Git checkout uses: actions/checkout@v4 # D3D12MA tests (main ComputeSharp tests) - name: Run ComputeSharp.Tests run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release /p:Platform=x64 /p:UseD3D12MemoryAllocator=true -v n -l "console;verbosity=detailed" # ビルドした NuGet パッケージ(.nupkg)を GitHub Release として公開する。 # GitHub Packages や Azure DevOps への push はフォークでは認証できず失敗する(403)ため、 # 代わりに自動生成のリリースノートを付けたリリースを作成し、.nupkg を資産として添付する。 publish-release: needs: [run-tests, run-tests-d3d12ma, build-packages] runs-on: windows-2022 if: ${{github.event_name == 'push'}} permissions: contents: write steps: - name: Git checkout uses: actions/checkout@v4 - name: Download package artifacts uses: actions/download-artifact@v4 with: name: nuget_packages path: artifacts - name: Create GitHub release with NuGet packages shell: bash env: GH_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | gh release create "build-${{github.sha}}" artifacts/*.nupkg \ --target "${{github.sha}}" \ --title "Nightly build ${{github.sha}}" \ --generate-notes \ --prerelease