Skip to content

Publish to NuGet

Publish to NuGet #1

Workflow file for this run

name: Publish to NuGet
on:
push:
tags:
- "v*" # Trigger when pushing tags like v1.0.0, v1.2.3, etc.
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build src/RouteCheck.csproj --configuration Release --no-restore
- name: Run tests
run: dotnet test tests/RouteCheck.tests.csproj --configuration Release --no-build
- name: Pack NuGet package
run: dotnet pack src/RouteCheck.csproj --configuration Release --no-build -o ./artifacts /p:PackageVersion=${GITHUB_REF_NAME#v}
# 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 to NuGet
run: dotnet nuget push "./artifacts/*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
files: ./artifacts/*.nupkg