Publish NuGet #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | |
| $packages = @(Get-ChildItem -Filter *.nupkg) | |
| if ($packages.Count -ne 1) { | |
| throw "Expected exactly one .nupkg file in artifacts/packages; found $($packages.Count)." | |
| } | |
| dotnet nuget push $packages[0].Name --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } | |
| finally { | |
| Pop-Location | |
| } |