Skip to content

Commit 285b80f

Browse files
committed
add Trusted Publishing
1 parent 9ab7e19 commit 285b80f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/nuget-publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ jobs:
4242
- name: Pack NuGet package
4343
run: dotnet pack SWEN3.Paperless.RabbitMq/SWEN3.Paperless.RabbitMq.csproj --configuration Release --no-build --output ./nupkg -p:GeneratePackageOnBuild=false
4444

45-
- name: Publish packages to NuGet.org
45+
- name: Publish packages to NuGet.org (Trusted Publishing)
4646
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
4747
run: |
48+
# Request OIDC token for NuGet Trusted Publishing
49+
OIDC_TOKEN=$(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
50+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r '.value')
51+
4852
dotnet nuget push ./nupkg/*.nupkg \
4953
--source https://api.nuget.org/v3/index.json \
50-
--api-key ${{ secrets.NUGET_API_KEY }} \
54+
--api-key "$OIDC_TOKEN" \
5155
--skip-duplicate

0 commit comments

Comments
 (0)