Skip to content

Commit fae76f2

Browse files
committed
Add a workflow for the CI
1 parent 6a6ec0a commit fae76f2

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# .github/workflows/dotnet.yml
2+
name: .NET CI
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v3
22+
with:
23+
dotnet-version: '7.x' # Specify the version or use 'latest' for the most recent
24+
25+
- name: Install dependencies
26+
run: dotnet restore
27+
28+
- name: Lint the code
29+
run: dotnet format --verify-no-changes
30+
continue-on-error: true
31+
32+
- name: Build the project
33+
run: dotnet build --no-restore --configuration Release
34+
35+
- name: Run unit tests
36+
run: dotnet test --no-build --configuration Release --verbosity normal
37+
38+
- name: Package the project
39+
run: dotnet pack --no-build --configuration Release -o ./artifacts
40+
41+
- name: Publish package to GitHub Packages
42+
if: github.ref == 'refs/heads/main' && success() # Publish only on successful builds of the main branch
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: dotnet nuget push ./artifacts/*.nupkg --source "github"

0 commit comments

Comments
 (0)