Skip to content

Commit 2793bc3

Browse files
authored
Merge pull request #330 from FriendsOfCADability/claude/github-actions-nuget-publish-qwvi8q
Fix NuGet Trusted Publishing: pass OIDC token directly as API key
2 parents 09b64bb + 2619232 commit 2793bc3

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

.github/workflows/nuget.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,11 @@ jobs:
2121
run: dotnet build CADability/CADability.csproj -c Release --no-restore
2222
- name: Pack
2323
run: dotnet pack CADability/CADability.csproj -c Release --no-build -o ./nupkgs
24-
- name: Get NuGet publish token
25-
run: |
26-
$tokenRequest = Invoke-RestMethod `
27-
-Uri "$env:ACTIONS_ID_TOKEN_REQUEST_URL&audience=nuget.org" `
28-
-Headers @{Authorization = "Bearer $env:ACTIONS_ID_TOKEN_REQUEST_TOKEN"}
29-
$body = ConvertTo-Json @{oidcToken = $tokenRequest.value}
30-
$nugetToken = (Invoke-RestMethod `
31-
-Method Post `
32-
-Uri "https://www.nuget.org/packages/publish/oidc" `
33-
-Body $body `
34-
-ContentType "application/json").token
35-
Write-Output "::add-mask::$nugetToken"
36-
echo "NUGET_TOKEN=$nugetToken" >> $env:GITHUB_ENV
3724
- name: Push NuGet package
3825
run: |
26+
$oidcToken = (Invoke-RestMethod `
27+
-Uri "$env:ACTIONS_ID_TOKEN_REQUEST_URL&audience=nuget.org" `
28+
-Headers @{Authorization = "Bearer $env:ACTIONS_ID_TOKEN_REQUEST_TOKEN"}).value
29+
Write-Output "::add-mask::$oidcToken"
3930
$pkg = Get-ChildItem -Path ./nupkgs -Filter "*.nupkg" | Select-Object -First 1
40-
dotnet nuget push "$($pkg.FullName)" --api-key "$env:NUGET_TOKEN" --source https://api.nuget.org/v3/index.json --skip-duplicate
31+
dotnet nuget push "$($pkg.FullName)" --api-key $oidcToken --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)