Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ on:
description: "Name of the workflow to check for successful builds"
secrets:
NUGET_TOKEN:
required: true
required: false
description: "Legacy API key. Ignored when NUGET_USER is set (Trusted Publishing)."
NUGET_USER:
required: false
description: "nuget.org profile name for Trusted Publishing (OIDC)"
WORKFLOW_PACKAGES:
required: true

Expand All @@ -39,6 +43,7 @@ env:
permissions:
actions: read
contents: write
id-token: write
pull-requests: write

jobs:
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/step-dotnet-publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ on:
description: "Name of the workflow to check for successful builds"
secrets:
NUGET_TOKEN:
required: true
required: false
description: "Legacy API key. Ignored when NUGET_USER is set (Trusted Publishing)."
NUGET_USER:
required: false
description: "nuget.org profile name for Trusted Publishing (OIDC)"
WORKFLOW_PACKAGES:
required: true

permissions:
contents: read
id-token: write

jobs:
nuget:
Expand All @@ -36,6 +41,9 @@ jobs:

environment: ${{ inputs.environment }}

env:
NUGET_USER: ${{ secrets.NUGET_USER }}

steps:
- name: Download artifacts from `${{ inputs.workflowName }}` workflow
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
Expand All @@ -46,6 +54,15 @@ jobs:
pattern: ${{ inputs.artifactPattern }}
run-id: ${{ inputs.runId }}

- name: NuGet login (Trusted Publishing)
id: login
if: ${{ env.NUGET_USER != '' }}
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
with:
user: ${{ env.NUGET_USER }}

- name: Publish NuGet Package
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY || secrets.NUGET_TOKEN }}
run: |
dotnet nuget push packages/**/*.nupkg -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push packages/**/*.nupkg -k "$NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate
Loading