Skip to content

Commit 89aec05

Browse files
oschwaldclaude
andcommitted
Add GitHub Actions workflow for NuGet trusted publishing
This workflow builds, tests, and publishes the NuGet package using OIDC-based trusted publishing instead of long-lived API keys. The publish job requires the 'nuget' environment which can be configured with required reviewers for release approval. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 361b1ae commit 89aec05

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build and publish to NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- published
12+
13+
permissions: {}
14+
15+
jobs:
16+
build:
17+
runs-on: windows-latest
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
submodules: true
22+
persist-credentials: false
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v5
26+
with:
27+
dotnet-version: |
28+
8.0.x
29+
9.0.x
30+
10.0.x
31+
32+
- name: Build
33+
run: dotnet build -c Release
34+
35+
- name: Run tests
36+
run: dotnet test -c Release
37+
env:
38+
MAXMIND_TEST_BASE_DIR: ${{ github.workspace }}/MaxMind.Db.Test
39+
40+
- name: Pack
41+
run: dotnet pack -c Release MaxMind.Db/MaxMind.Db.csproj
42+
43+
- name: Upload artifacts
44+
uses: actions/upload-artifact@v5
45+
with:
46+
name: nuget-packages
47+
path: MaxMind.Db/bin/Release/*.nupkg
48+
49+
publish:
50+
needs: build
51+
runs-on: windows-latest
52+
environment: nuget
53+
permissions:
54+
id-token: write
55+
if: github.event_name == 'release' && github.event.action == 'published'
56+
steps:
57+
- name: Download artifacts
58+
uses: actions/download-artifact@v6
59+
with:
60+
name: nuget-packages
61+
path: packages
62+
63+
- name: NuGet login
64+
uses: nuget/login@v1
65+
with:
66+
user: maxmind
67+
68+
- name: Push to NuGet
69+
run: dotnet nuget push packages/*.nupkg --api-key "${{ env.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)