Skip to content

Commit 57f9968

Browse files
committed
Fix NuGet publish workflow secret gating
1 parent 23daa53 commit 57f9968

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/publish-dotnet-tool.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,31 @@ jobs:
6363
name: dnakode-vbnet-lsp-nuget
6464
path: out/nuget/*.nupkg
6565

66+
- name: Check NuGet key availability
67+
id: nuget_key
68+
shell: bash
69+
env:
70+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
71+
run: |
72+
set -euo pipefail
73+
if [[ -n "${NUGET_API_KEY:-}" ]]; then
74+
echo "present=true" >> "$GITHUB_OUTPUT"
75+
else
76+
echo "present=false" >> "$GITHUB_OUTPUT"
77+
fi
78+
6679
- name: Publish package to NuGet
67-
if: ${{ secrets.NUGET_API_KEY != '' }}
80+
if: ${{ steps.nuget_key.outputs.present == 'true' }}
6881
shell: bash
82+
env:
83+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
6984
run: |
7085
set -euo pipefail
7186
dotnet nuget push out/nuget/*.nupkg \
72-
--api-key "${{ secrets.NUGET_API_KEY }}" \
87+
--api-key "${NUGET_API_KEY}" \
7388
--source "https://api.nuget.org/v3/index.json" \
7489
--skip-duplicate
7590
7691
- name: Skip publish (missing NUGET_API_KEY)
77-
if: ${{ secrets.NUGET_API_KEY == '' }}
92+
if: ${{ steps.nuget_key.outputs.present != 'true' }}
7893
run: echo "NUGET_API_KEY is not configured; package was built and uploaded as an artifact only."

0 commit comments

Comments
 (0)