Skip to content

Commit 51177c5

Browse files
committed
Added publish GitHub workflow
1 parent a1b5249 commit 51177c5

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

.github/workflows/publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
id-token: write
11+
contents: read
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: |
25+
10.0.x
26+
27+
- name: Install Cake
28+
run: dotnet tool restore
29+
30+
- name: NuGet login (OIDC)
31+
uses: NuGet/login@v1
32+
id: login
33+
with:
34+
user: ${{ secrets.NUGET_USER }}
35+
36+
- name: Run Cake Publish target
37+
run: dotnet cake --target=Publish --nugetApiKey=${{ steps.login.outputs.apikey }}

build.cake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var configuration = Argument("configuration", "Release");
99
var netfx = Argument("netfx", "net472");
1010
var netcore = Argument("netcore", "net8.0");
1111
var netcoreVersion = Argument("netcoreVersion", "");
12+
var nugetApiKey = Argument("nugetApiKey", "");
1213

1314
//////////////////////////////////////////////////////////////////////
1415
// CONSTANTS
@@ -245,9 +246,11 @@ Task("Publish")
245246
{
246247
foreach(var package in System.IO.Directory.GetFiles(PACKAGE_DIR, "*.nupkg").Where(o => !o.Contains("symbols")))
247248
{
248-
NuGetPush(package, new NuGetPushSettings()
249+
DotNetNuGetPush(package, new DotNetNuGetPushSettings()
249250
{
250-
Source = "https://api.nuget.org/v3/index.json"
251+
Source = "https://api.nuget.org/v3/index.json",
252+
ApiKey = nugetApiKey,
253+
SkipDuplicate = true
251254
});
252255
}
253256
});

0 commit comments

Comments
 (0)