Skip to content

Commit 43f3508

Browse files
Sandounclaude
andcommitted
Use NuGet trusted publishing (OIDC) for nuget.org push
Replaces the long-lived NUGET_TOKEN secret with a short-lived API key obtained via GitHub Actions OIDC through the NuGet/login action, per https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing. The GitHub Packages push is unaffected and still uses GITHUB_TOKEN. Requires a NUGET_USER repo secret (nuget.org username) and a Trusted Publishing policy configured on nuget.org for this repo/workflow file. The NUGET_TOKEN secret can be removed once this is verified working. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent fed8989 commit 43f3508

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/publish-pipeline.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,23 @@ jobs:
144144
- name: Pack as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}
145145
run: dotnet pack "MewtocolNet" -c:Release
146146

147-
- name: Publish as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}
148-
run: |
147+
- name: Publish to GitHub Packages as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}
148+
run: |
149149
cd '${{ github.workspace }}/Builds/MewtocolNet'
150150
ls -l
151151
dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
152-
dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source "https://api.nuget.org/v3/index.json"
153-
152+
153+
- name: NuGet login (OIDC trusted publishing)
154+
uses: NuGet/login@v1
155+
id: nuget_login
156+
with:
157+
user: ${{ secrets.NUGET_USER }}
158+
159+
- name: Publish to NuGet.org as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}
160+
run: |
161+
cd '${{ github.workspace }}/Builds/MewtocolNet'
162+
dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ steps.nuget_login.outputs.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json"
163+
154164
- name: 'Create Release v${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}'
155165
id: create_release
156166
uses: actions/create-release@v1

0 commit comments

Comments
 (0)