1
0

Publish a nuget package with optional restriction to a name

This commit is contained in:
2026-04-09 20:30:50 +02:00
parent 9412092d94
commit a9ea3670cc
2 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
name: 'publish-nuget'
description: 'Publishes a NuGet package.'
inputs:
api-key:
description: 'The API key to use for publishing the package.'
required: true
package-name:
description: 'The name of the NuGet package contains (contains check).'
default: ''
source-url:
description: 'The URL of the NuGet server to publish to. Defaults to https://api.nuget.org/v3/index.json.'
default: 'https://api.nuget.org/v3/index.json'
runs:
using: 'composite'
steps:
- name: Publish NuGet package(s)
shell: bash
run: |
nugetFiles=$(find . -type f -name "*.nupkg")
if [ -n "${{ inputs.package-name }}" ]; then
nugetFiles=$(echo "$nugetFiles" | grep "${{ inputs.package-name }}")
fi
for nugetFile in $nugetFiles; do
echo "Publishing package: $(basename "$nugetFile")"
dotnet nuget push "$nugetFile" --api-key "${{ inputs.api-key }}" --source "${{ inputs.source-url }}" --skip-duplicate
done