Skip to content

Publish NuGet Package #2

Publish NuGet Package

Publish NuGet Package #2

name: Publish NuGet Package
on:
release:
types: [created]
workflow_dispatch:
# Add explicit permissions
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Debug Event
run: |
echo "Event name: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
echo "Release tag: ${{ github.event.release.tag_name }}"
- uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }} # Explicitly checkout the tag
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Pack
run: dotnet pack --configuration Release --no-build
- name: List packages
run: find . -name "*.nupkg" | sort
- name: Push to GitHub Packages
run: dotnet nuget push "**/*.nupkg" --source https://nuget.pkg.github.com/tomas-rampas/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate