Skip to content

Commit 956b68d

Browse files
committed
Update CI scripts
Add release build Add publish yml
1 parent a495867 commit 956b68d

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

.github/workflows/dotnet.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
name: .NET
55

66
on:
7-
push:
8-
branches: [ "main" ]
97
pull_request:
108
branches: [ "main" ]
9+
push:
10+
branches: [ "main" ]
1111

1212
jobs:
1313
build:
14-
14+
name: ".NET / build"
1515
runs-on: windows-latest
1616

1717
steps:
@@ -24,5 +24,9 @@ jobs:
2424
run: dotnet restore
2525
- name: Build
2626
run: dotnet build --no-restore
27+
- name: Build release
28+
run: dotnet build --configuration Release --no-restore
2729
- name: Test
2830
run: dotnet test --no-build --verbosity normal
31+
- name: Test release
32+
run: dotnet test --configuration Release --no-build --verbosity normal

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Publishes a .NET package to NuGet when a new tag is pushed.
2+
3+
name: Publish NuGet Package
4+
5+
on:
6+
push:
7+
tags: ['v*.*.*'] # fires on v0.1.0, v0.1.0-rc.1, etc.
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish:
12+
name: ".NET / Publish"
13+
runs-on: windows-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with: { fetch-depth: 0 }
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: 9.0.x
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
- name: Build
25+
run: dotnet build -c Release --no-restore
26+
- name: Pack
27+
run: dotnet pack -c Release --no-build -o ./artifacts
28+
- name: Publish to NuGet
29+
run: |
30+
Get-ChildItem -Path ./artifacts -Filter *.nupkg | ForEach-Object {
31+
dotnet nuget push $_.FullName `
32+
--api-key ${{ secrets.NUGET_API_KEY }} `
33+
--source https://api.nuget.org/v3/index.json `
34+
--skip-duplicate
35+
}

0 commit comments

Comments
 (0)