Skip to content

Publish to NuGet

Publish to NuGet #5

Workflow file for this run

# Note this will only work with Release-Please if you have given it a PAT.
# The default GITHUB_TOKEN does not have permission to run workflows on releases
name: Publish to NuGet
on:
release:
types: [published]
workflow_dispatch:
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v5
- name: Setup DotNet ✨
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.0.x"
- name: Install dependencies 📦️
run: dotnet restore
# - name: Build 🔨
# run: dotnet build --no-restore -c Release ./src/RazorLight/RazorLight.csproj
# If not using <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
- name: Build 🔨 & Pack NuGet 🏗️
run: |
dotnet pack -v normal --include-symbols -o nupkg
# Get a short-lived NuGet API key
- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{secrets.NUGET_USER}}
- name: Push NuGet 🚀
run: |
dotnet nuget push **/*.nupkg -k ${{steps.login.outputs.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate