Skip to content

Commit ffbf47b

Browse files
sunnamed434claude
andcommitted
Use NuGet Trusted Publishing (OIDC) instead of static API key
Exchange the GitHub OIDC token for a short-lived NuGet key via NuGet/login@v1 at push time, dropping the long-lived NUGET_DEPLOY_KEY. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 04282c3 commit ffbf47b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/RocketModFix.UnityEngine.Redist.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212
build:
1313
name: "RocketModFix.UnityEngine.Redist Pack"
1414
runs-on: ubuntu-22.04
15+
# Trusted Publishing: id-token lets NuGet/login mint a short-lived key via OIDC.
16+
permissions:
17+
contents: read
18+
id-token: write
1519
steps:
1620
- uses: actions/checkout@v7
1721

@@ -27,11 +31,17 @@ jobs:
2731
- uses: nuget/setup-nuget@v4
2832
name: Setup NuGet
2933
with:
30-
nuget-api-key: ${{ secrets.NUGET_DEPLOY_KEY }}
3134
nuget-version: '5.x'
32-
35+
3336
- name: Pack
3437
run: nuget pack redist/RocketModFix.UnityEngine.Redist.nuspec
3538

39+
# Exchange the GitHub OIDC token for a ~1h NuGet key, right before push.
40+
- name: NuGet login (OIDC -> temp API key)
41+
uses: NuGet/login@v1
42+
id: nuget-login
43+
with:
44+
user: ${{ secrets.NUGET_USER }}
45+
3646
- name: Push to NuGet
37-
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_DEPLOY_KEY }} --source https://api.nuget.org/v3/index.json
47+
run: dotnet nuget push *.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)