Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Publish to NuGet

Publish to NuGet #10

Workflow file for this run

name: Publish to NuGet
on:
release:
types: [created]
workflow_dispatch:
inputs:
version:
description: 'Package version (e.g., 1.0.0)'
required: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build
run: dotnet build --configuration Release
- name: Pack
run: dotnet pack --configuration Release --no-build --output ./artifacts
- name: List packages
run: |
echo "Contents of artifacts directory:"
ls -la ./artifacts/ || echo "Directory not found"
echo "Looking for .nupkg files:"
find ./artifacts -name "*.nupkg" 2>/dev/null || echo "No packages found"
- name: Publish to NuGet
run: |
for package in ./artifacts/*.nupkg; do
if [ -f "$package" ]; then
echo "Publishing $package..."
dotnet nuget push "$package" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
fi
done