Skip to content

Commit 14c14c4

Browse files
ChaseDRedmonclaude
andauthored
Add NuGet release workflow (#7)
Adds GitHub Actions workflow to publish NuGet package when version tags are pushed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent eb29d2e commit 14c14c4

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish NuGet Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # e.g., v1.0.0, v1.2.3
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 1. Checkout repository
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
# 2. Install .NET 10 SDK
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v5
20+
with:
21+
dotnet-version: '10.0.x'
22+
23+
# 3. Extract version number from Git tag
24+
- name: Extract version from tag
25+
id: get_version
26+
run: |
27+
VERSION=${GITHUB_REF#refs/tags/v}
28+
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
29+
30+
# 4. Restore dependencies for the library
31+
- name: Restore library dependencies
32+
run: dotnet restore src/CatBox.NET/CatBox.NET.csproj
33+
34+
# 5. Build the library
35+
- name: Build library
36+
run: dotnet build src/CatBox.NET/CatBox.NET.csproj --configuration Release --no-restore
37+
38+
# 6. Run tests (pointing to your test project)
39+
- name: Run tests
40+
run: dotnet test tests/CatBox.Tests/CatBox.Tests.csproj --configuration Release --no-build
41+
42+
# 7. Pack the NuGet package
43+
- name: Pack NuGet package
44+
run: dotnet pack src/CatBox.NET/CatBox.NET.csproj --configuration Release --no-build -o ./artifacts /p:PackageVersion=${{ env.PACKAGE_VERSION }}
45+
46+
# 8. Publish package to nuget.org
47+
- name: Publish NuGet package
48+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)