Skip to content

Commit b6bbb02

Browse files
JusterZhuclaude
andcommitted
fix(ci): add NuGet/login@v1 for OIDC trusted publishing
- Use NuGet/login@v1 to exchange OIDC token for temporary NuGet API key - Use NUGET_USER secret (juster.chu) for NuGet.org login - No long-lived API key secrets needed anymore Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1d074dd commit b6bbb02

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.github/workflows/dotnet-ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@ jobs:
5656
if ($failed) { Write-Host "部分包打包时有警告,但继续执行" }
5757
shell: pwsh
5858

59+
- name: 登录 nuget.org (OIDC → 临时 API Key)
60+
uses: NuGet/login@v1
61+
id: login
62+
with:
63+
user: ${{ secrets.NUGET_USER }}
64+
5965
- name: 推送NuGet包到 nuget.org
6066
continue-on-error: true # 即便推送失败也继续创建GitHub Release
6167
run: |
68+
$apiKey = '${{ steps.login.outputs.NUGET_API_KEY }}'
6269
$nupkgs = Get-ChildItem ./nupkgs/*.nupkg
6370
foreach ($nupkg in $nupkgs) {
6471
Write-Host "推送 $($nupkg.Name)..."
6572
dotnet nuget push $nupkg.FullName `
73+
--api-key $apiKey `
6674
--source https://api.nuget.org/v3/index.json `
6775
--skip-duplicate
6876
}

0 commit comments

Comments
 (0)