Make NuGet publish secure #3
This file contains hidden or 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
| name: continuous | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| - 'release/*' | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| - name: Run './build.cmd Verify Cover Pack' | |
| run: ./build.cmd Verify Cover Pack --no-logo | |
| - name: Collect NuGet for publish | |
| uses: actions/upload-artifact@v7 | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| with: | |
| path: 'artifacts' | |
| name: 'nuget-packages' | |
| publish: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| id-token: write | |
| environment: nuget-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: nuget-packages | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: nugetLogin | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push to NuGet | |
| run: dotnet nuget push **/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json | |
| env: | |
| NUGET_API_KEY: ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} |