Publish a nuget package with optional restriction to a name
This commit is contained in:
30
win/publish-nuget/action.yml
Normal file
30
win/publish-nuget/action.yml
Normal 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: powershell
|
||||
run: |
|
||||
$nugetFiles = Get-ChildItem -Recurse -File -Filter "*.nupkg"
|
||||
|
||||
if (![string]::IsNullOrWhiteSpace("${{ inputs.package-name }}")) {
|
||||
$nugetFiles = $nugetFiles | Where-Object { $_.BaseName -match "${{ inputs.package-name }}" }
|
||||
}
|
||||
|
||||
foreach ($nugetFile in $nugetFiles) {
|
||||
Write-Host "Publishing package: $($nugetFile.Name)"
|
||||
dotnet nuget push "$($nugetFile.FullName)" --api-key "${{ inputs.api-key }}" --source "${{ inputs.source-url }}" --skip-duplicate
|
||||
}
|
||||
Reference in New Issue
Block a user