Skip to content

Commit 509d313

Browse files
ci: migrate NuGet publish to trusted publishing (OIDC)
Replace long-lived NUGET_API_KEY secret with short-lived OIDC token via NuGet/login@v1. Adds id-token: write permission and NUGET_USER secret reference to the deploy job.
1 parent 445980c commit 509d313

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/Deploy.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,25 @@ jobs:
5050
name: "Production"
5151
url: "https://www.nuget.org/packages/IntelliTect.Analyzers"
5252
name: Push NuGets
53+
permissions:
54+
id-token: write # Required for NuGet trusted publishing (OIDC)
55+
contents: read
5356

5457
steps:
5558
- name: Download artifact from build job
5659
uses: actions/download-artifact@v8
5760
with:
5861
name: NuGet
5962

63+
- name: NuGet login (OIDC)
64+
id: login
65+
uses: NuGet/login@v1
66+
with:
67+
user: ${{ secrets.NUGET_USER }} # nuget.org profile name (NOT email)
68+
6069
- name: Push NuGet
6170
run: |
6271
$tagVersion = "${{ github.ref }}".substring(11)
6372
echo "TAG_VERSION=$tagVersion" >> $env:GITHUB_OUTPUT
64-
dotnet nuget push IntelliTect.Analyzers.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
73+
dotnet nuget push IntelliTect.Analyzers.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate
6574
id: tag-version

0 commit comments

Comments
 (0)