Skip to content

Commit f9b5d82

Browse files
committed
Add NuGet publish workflow to automate package deployment
1 parent b91a652 commit f9b5d82

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish NuGet Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
- '[0-9]+.[0-9]+.[0-9]+-*'
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Extract version from tag
18+
id: get_version
19+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
20+
21+
- name: Setup .NET 9.0
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: '9.0.x'
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet build --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }}
31+
32+
- name: Pack
33+
run: dotnet pack --configuration Release --no-build --output ./artifacts /p:Version=${{ steps.get_version.outputs.VERSION }}
34+
35+
- name: Push to NuGet
36+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
37+
38+
- name: Create GitHub Release
39+
uses: softprops/action-gh-release@v1
40+
with:
41+
files: ./artifacts/*.nupkg
42+
generate_release_notes: true
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/NullOpsDevs.Bootstrap.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ EndProject
77
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI-CD", "CI-CD", "{816B745E-8A54-4CE9-A285-945EC121D5A9}"
88
ProjectSection(SolutionItems) = preProject
99
..\.github\workflows\docs-workflow.yml = ..\.github\workflows\docs-workflow.yml
10+
..\.github\workflows\nuget-publish.yml = ..\.github\workflows\nuget-publish.yml
1011
EndProjectSection
1112
EndProject
1213
Global

0 commit comments

Comments
 (0)