Skip to content

Commit 1bc9b27

Browse files
Use NuGet/login@v1 action instead of manual OIDC curl for trusted publishing
Agent-Logs-Url: https://github.com/crispthinking/FastText.NetWrapper/sessions/1e170fc6-c3a2-4651-85a5-ab9e754e253f Co-authored-by: corpo-iwillspeak <265613520+corpo-iwillspeak@users.noreply.github.com>
1 parent 94867f2 commit 1bc9b27

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

.github/workflows/publish.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ jobs:
3131
- name: Publish NuGet Packages to GitHub Packages
3232
run: dotnet nuget push bin/artifacts/**/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate
3333

34+
- name: NuGet login (OIDC → temp API key)
35+
if: github.event_name == 'release'
36+
uses: NuGet/login@v1
37+
id: login
38+
with:
39+
user: ${{ secrets.NUGET_USER }}
40+
3441
- name: Publish NuGet package
3542
if: github.event_name == 'release'
36-
run: |
37-
OIDC_TOKEN=$(curl --silent --show-error --fail-with-body \
38-
--url "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" \
39-
--header "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
40-
| jq --raw-output '.value')
41-
API_KEY=$(curl --silent --show-error --fail-with-body \
42-
--request POST \
43-
--url "https://api.nuget.org/v1/authentication/authenticate" \
44-
--header "Content-Type: application/json" \
45-
--data "{\"oidcToken\": \"$OIDC_TOKEN\"}" \
46-
| jq --raw-output '.apiKey')
47-
dotnet nuget push bin/artifacts/**/*.nupkg --api-key "$API_KEY" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
43+
run: dotnet nuget push bin/artifacts/**/*.nupkg --api-key "${{ steps.login.outputs.apiKey }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate

0 commit comments

Comments
 (0)