Skip to content

Commit acf2306

Browse files
committed
Add GitHub Actions workflow for testing and publishing
Added a `nuget.yml` workflow to automate testing and publishing of a .NET project to NuGet. The workflow triggers on `push` events for tags matching semantic versioning patterns (`*.*.*`). The workflow includes two jobs: - `test`: Runs on a matrix of OS environments (Ubuntu, Windows, macOS) to restore dependencies, build the project, and run tests using multiple .NET versions (6.0.x, 7.0.x, 8.0.x, 9.0.x). - `publish`: Runs after successful tests, builds the project, creates a NuGet package, and pushes it to NuGet.org using a secure API key from GitHub Secrets.
1 parent 08aba48 commit acf2306

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/nuget.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish to NuGet
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
test:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, windows-latest, macos-latest]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: |
22+
6.0.x
23+
7.0.x
24+
8.0.x
25+
9.0.x
26+
27+
- name: Restore dependencies
28+
run: dotnet restore
29+
30+
- name: Build
31+
run: dotnet build --no-restore --configuration Release
32+
33+
- name: Run tests
34+
run: dotnet test --no-build --configuration Release --verbosity normal
35+
36+
publish:
37+
needs: test
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Setup .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: |
47+
6.0.x
48+
7.0.x
49+
8.0.x
50+
9.0.x
51+
52+
- name: Restore dependencies
53+
run: dotnet restore
54+
55+
- name: Build
56+
run: dotnet build --no-restore --configuration Release
57+
58+
- name: Pack Hexa.NET.Utilities
59+
run: dotnet pack Hexa.NET.Utilities/Hexa.NET.Utilities.csproj --no-build --configuration Release --output ./artifacts
60+
61+
- name: Push to NuGet
62+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)