Skip to content

Commit 31522af

Browse files
committed
⚙️ Add NuGet trusted publishing via OIDC to CI workflow
1 parent 1eef529 commit 31522af

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags: ['[0-9]*.*']
67
pull_request:
78
branches: [main]
9+
workflow_dispatch:
10+
11+
env:
12+
DOTNET_NOLOGO: true
813

914
jobs:
1015
build:
@@ -26,3 +31,35 @@ jobs:
2631
- run: just build-release
2732

2833
- run: just test-release
34+
35+
- uses: actions/upload-artifact@v4
36+
if: matrix.os == 'ubuntu-latest' && (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch')
37+
with:
38+
name: nuget
39+
if-no-files-found: error
40+
path: |
41+
src/CronTimer/bin/Release/*.nupkg
42+
src/CronTimer/bin/Release/*.snupkg
43+
44+
publish:
45+
needs: build
46+
if: github.event_name == 'workflow_dispatch'
47+
runs-on: ubuntu-latest
48+
permissions:
49+
id-token: write
50+
steps:
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: nuget
54+
path: artifacts
55+
56+
- uses: actions/setup-dotnet@v4
57+
with:
58+
dotnet-version: 10.x
59+
60+
- uses: NuGet/login@v1
61+
id: login
62+
with:
63+
user: ${{ secrets.NUGET_USER }}
64+
65+
- run: dotnet nuget push 'artifacts/*.nupkg' -s https://api.nuget.org/v3/index.json -k ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate

0 commit comments

Comments
 (0)