Skip to content

Commit ceb25f4

Browse files
committed
fix: handle missing NuGet API key in publish workflow
1 parent adbe91c commit ceb25f4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ jobs:
4444
run: dotnet pack src/CodeContext.CLI/CodeContext.CLI.csproj --configuration Release --no-build -p:Version=${{ env.VERSION }} -o ./artifacts
4545

4646
- name: Push to NuGet
47-
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
47+
env:
48+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
49+
run: |
50+
if [ -z "$NUGET_API_KEY" ]; then
51+
echo "Warning: NUGET_API_KEY not set. Skipping NuGet push."
52+
echo "To enable automatic publishing, add NUGET_API_KEY to repository secrets."
53+
exit 0
54+
fi
55+
dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)