Version 3.1.3 #3
Workflow file for this run
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 Release | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| publish-nuget: | |
| name: Publish to NuGet.org | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download release assets | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release download "${{ github.event.release.tag_name }}" \ | |
| --pattern "*.nupkg" \ | |
| --dir ./artifacts \ | |
| --repo "${{ github.repository }}" | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Verify packages | |
| run: | | |
| echo "Packages to be published:" | |
| ls -la ./artifacts/*.nupkg | |
| # Verify package count | |
| PACKAGE_COUNT=$(ls ./artifacts/*.nupkg | wc -l) | |
| if [ "$PACKAGE_COUNT" -eq 0 ]; then | |
| echo "Error: No packages found!" | |
| exit 1 | |
| fi | |
| echo "Found $PACKAGE_COUNT package(s) to publish" | |
| - name: Publish to NuGet.org | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| for package in ./artifacts/*.nupkg; do | |
| echo "Publishing $package to NuGet.org..." | |
| dotnet nuget push "$package" \ | |
| --api-key "$NUGET_API_KEY" \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| done | |
| echo "All packages published successfully!" | |
| - name: Upload published packages as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: published-nuget-packages | |
| path: ./artifacts/*.nupkg | |
| retention-days: 90 |