A semantic-release plugin to build and publish NuGet packages automatically for .NET projects.
- Detects the next release version from
semantic-release - Runs:
dotnet build --configuration Releasedotnet packwith the same versiondotnet nuget pushto publish to nuget.org
All automatically in the publish step of semantic-release.
npm install --save-dev @gabbium/semantic-release-nugetIn your .releaserc (or release.config.js), add the plugin after your standard plugins:
{
"branches": ["main"],
"plugins": [
"@gabbium/semantic-release-nuget",
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/git",
"@semantic-release/github"
]
}You need to provide:
GITHUB_TOKEN→ for semantic-release GitHub integrationNUGET_TOKEN→ your NuGet.org API key
In GitHub Actions, you would set it like:
- name: Run semantic-release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}This plugin hooks into the publish step of semantic-release:
- Uses the
nextRelease.versionprovided by semantic-release - Builds the project with
dotnet build --configuration Release - Packs a NuGet with
/p:Version=${nextRelease.version} - Pushes the
.nupkgto nuget.org usingdotnet nuget push
name: Release
on:
push:
branches: ["main"]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 23.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
- name: Install deps
run: npm ci
- name: Run semantic-release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}This project is licensed under the MIT License – see LICENSE for details.