From b2c906f54ee11e150c1a6fcb7f635faeda1dfb7b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 24 Nov 2025 18:49:59 +0000 Subject: [PATCH] Add NuGet packaging and GitHub Packages upload to CI Add three new steps to the CI workflow: 1. Pack NuGet package: - Builds Release configuration of Scrutor.csproj - Outputs to ./artifacts directory - Creates deterministic .nupkg and .snupkg files 2. Upload NuGet package artifact: - Makes packages available as GitHub Actions artifacts - Useful for debugging and manual downloads - Preserved for workflow retention period 3. Push to GitHub Packages: - Only runs on push events (not pull requests) - Only runs on khellang/* repositories - Uses GITHUB_TOKEN for authentication - Skips duplicates to avoid errors on re-runs - Publishes to GitHub's NuGet feed This enables automatic package distribution on every push while maintaining deterministic, reproducible builds. --- .github/workflows/build.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6b4f14c..3dc1b1f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,3 +35,16 @@ jobs: files: coverage.cobertura.xml token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false + + - name: Pack NuGet package + run: dotnet pack src/Scrutor/Scrutor.csproj --configuration Release --output ./artifacts + + - name: Upload NuGet package artifact + uses: actions/upload-artifact@v4 + with: + name: nuget-packages + path: ./artifacts/*.nupkg + + - name: Push to GitHub Packages + if: github.event_name == 'push' && startsWith(github.repository, 'khellang/') + run: dotnet nuget push ./artifacts/*.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate