Skip to content

Commit 8323c0b

Browse files
authored
Create nuget-publish.yml
1 parent 8d64956 commit 8323c0b

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Publish NuGet Packages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
environment: production
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: |
23+
8.0.x
24+
9.0.x
25+
10.0.x
26+
27+
- name: Restore
28+
run: dotnet restore
29+
30+
- name: Build (Release)
31+
run: dotnet build -c Release --no-restore
32+
33+
- name: Pack (nupkg + snupkg)
34+
run: |
35+
dotnet pack -c Release \
36+
--no-build \
37+
-o ./nupkgs \
38+
/p:IncludeSymbols=true \
39+
/p:SymbolPackageFormat=snupkg
40+
41+
- name: List packages
42+
run: ls -la ./nupkgs
43+
44+
- name: Publish to NuGet (Trusted Publishing)
45+
run: |
46+
echo "🚀 Publishing packages..."
47+
48+
for f in ./nupkgs/*.nupkg; do
49+
echo "📦 Publishing $f"
50+
51+
dotnet nuget push "$f" \
52+
--source https://api.nuget.org/v3/index.json \
53+
--skip-duplicate \
54+
|| echo "❌ Failed: $f (continuing...)"
55+
done
56+
57+
- name: Done
58+
run: echo "✅ Publish process completed"

0 commit comments

Comments
 (0)