Skip to content

Publish NuGet

Publish NuGet #2

Workflow file for this run

name: Publish NuGet
on:
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore ColorSampler.slnx
- name: Build
run: dotnet build ColorSampler.slnx -c Release --no-restore
- name: Pack
run: dotnet pack src/ColorSampler/ColorSampler.csproj -c Release --no-build -o artifacts/packages
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: Ph0rd
- name: Publish
shell: pwsh
run: |
Push-Location artifacts/packages
try {
$package = Get-ChildItem -Filter *.nupkg | Select-Object -First 1
if (-not $package) {
throw "No .nupkg file found in artifacts/packages."
}
dotnet nuget push $package.Name --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
finally {
Pop-Location
}