Skip to content

Commit e9c640d

Browse files
committed
Run tests on PRs
1 parent 2dc70c5 commit e9c640d

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

.github/workflows/ci-cd.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ on:
77
branches:
88
- 'main' # Run the workflow when pushing to the main branch
99
- 'develop' # Also run on develop, but skip publishing
10+
pull_request:
11+
branches:
12+
- 'main' # Run tests on PRs targeting main
13+
- 'develop' # Run tests on PRs targeting develop
1014

1115
env:
1216
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
1317
DOTNET_NOLOGO: true
1418
NuGetDirectory: ${{ github.workspace}}/.nuget
1519

1620
jobs:
17-
publish:
18-
runs-on: ubuntu-latest
21+
build:
22+
runs-on: &runner ubuntu-latest
1923

2024
steps:
2125
- name: Checkout
2226
uses: actions/checkout@v4
23-
27+
2428
- name: Setup .NET
2529
uses: actions/setup-dotnet@v4
2630
with:
@@ -35,11 +39,31 @@ jobs:
3539
run: dotnet build --configuration Release --no-restore
3640

3741
- name: Run tests
38-
run: dotnet test --no-restore
39-
42+
run: dotnet test --configuration Release --no-build --no-restore
43+
4044
- name: Create NuGet package
45+
if: github.event_name == 'push'
4146
run: dotnet pack --configuration Release --no-restore --output ${{ env.NuGetDirectory }}
4247

48+
- name: Upload package artifact
49+
if: github.event_name == 'push'
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: nuget-packages
53+
path: ${{ env.NuGetDirectory }}/*.nupkg
54+
if-no-files-found: error
55+
56+
publish:
57+
needs: build
58+
if: github.event_name == 'push' && github.ref_name == 'main'
59+
runs-on: *runner
60+
61+
steps:
62+
- name: Download package artifact
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: nuget-packages
66+
path: ${{ env.NuGetDirectory }}
67+
4368
- name: Publish NuGet package
44-
if: github.ref_name == 'main'
4569
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)