Skip to content
Merged
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
27 changes: 21 additions & 6 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
permissions:
contents: write
packages: write
id-token: write # NuGet.org Trusted Publishing (OIDC) için gerekli

jobs:
build-and-publish:
Expand Down Expand Up @@ -214,18 +215,32 @@ jobs:
path: packages/
retention-days: 30

# Trusted Publishing: GitHub'ın OIDC token'ı NuGet.org'a gönderilir ve
# 1 saat geçerli, tek kullanımlık kısa ömürlü bir API key alınır.
# Anahtar kısa ömürlü olduğu için bu adım push'tan hemen önce çalışmalıdır.
# NuGet.org policy'si bu workflow dosya adına (publish-nuget.yml) bağlıdır;
# dosyayı yeniden adlandırırsanız policy'yi de güncellemek gerekir.
- name: NuGet login (OIDC → short-lived API key)
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}

- name: Publish to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: |
# Check if API key is configured
# Verify the OIDC token exchange produced a key
if [ -z "$NUGET_API_KEY" ]; then
echo "❌ Error: NUGET_API_KEY secret is not configured"
echo "Please add your NuGet.org API key as a repository secret named 'NUGET_API_KEY'"
echo "Get your API key from: https://www.nuget.org/account/apikeys"
echo "❌ Error: Trusted Publishing did not return an API key"
echo "Checklist:"
echo " - NUGET_USER secret must be your nuget.org profile name (not e-mail)"
echo " - nuget.org Trusted Publishing policy must match:"
echo " owner=${{ github.repository_owner }}, repo=${{ github.event.repository.name }}, workflow=publish-nuget.yml"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid hard‑coding the workflow file name and prefer github.workflow/github.repository for the diagnostic message.

This checklist line hard-codes workflow=publish-nuget.yml and relies on github.event.repository.name, which isn’t available for all event types and could break if triggers change. Using workflow=${{ github.workflow }} and repo=${{ github.repository }} keeps the message accurate and robust if the workflow file is renamed or the event type changes, without requiring manual updates to the text.

Suggested change
echo " owner=${{ github.repository_owner }}, repo=${{ github.event.repository.name }}, workflow=publish-nuget.yml"
echo " owner=${{ github.repository_owner }}, repo=${{ github.repository }}, workflow=${{ github.workflow }}"

echo " - Job must have 'id-token: write' permission"
exit 1
fi

echo "🚀 Publishing packages to NuGet.org..."

FORCE_FLAG=""
Expand Down
Loading