Skip to content

Commit 55f8599

Browse files
Merge pull request #75 from crispthinking/copilot/switch-to-trusted-publishing
Switch NuGet publishing to Trusted Publishing (OIDC)
2 parents 120a789 + b5e6533 commit 55f8599

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ env:
1616
jobs:
1717
build:
1818
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
checks: write # Required for dorny/test-reporter to create check runs
1922
steps:
2023
- uses: actions/checkout@v6
2124
with:
@@ -63,6 +66,9 @@ jobs:
6366
deploy:
6467
runs-on: ubuntu-latest
6568
needs: [ build ]
69+
permissions:
70+
packages: write # Required to publish to GitHub Packages
71+
id-token: write # Required for NuGet trusted publishing (OIDC)
6672
steps:
6773
# Download the NuGet package created in the previous job
6874
- uses: actions/download-artifact@v8
@@ -81,7 +87,14 @@ jobs:
8187
run: |
8288
dotnet nuget push ${NuGetDirectory}/*.nupkg --api-key "${{ secrets.GITHUB_TOKEN }}" --source "https://nuget.pkg.github.com/crispthinking/index.json" --skip-duplicate
8389
90+
- name: NuGet login (OIDC → temp API key)
91+
if: github.event_name == 'release'
92+
uses: NuGet/login@v1
93+
id: login
94+
with:
95+
user: ${{ secrets.NUGET_USER }}
96+
8497
- name: Publish NuGet package
8598
if: github.event_name == 'release'
8699
run: |
87-
dotnet nuget push ${NuGetDirectory}/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
100+
dotnet nuget push ${NuGetDirectory}/*.nupkg --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate

0 commit comments

Comments
 (0)