-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (85 loc) · 3.02 KB
/
test-build-push-nuget.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Test dependent packaging
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
proj: [Monitoring.Test, Monitoring.Web.Test]
defaults:
run:
working-directory: ./src
name: Unit testing - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Build test project and run tests
if: env.PACKAGE_PROJECT_NAME != ''
run: |
dotnet test './${{ env.PACKAGE_PROJECT_NAME }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' --logger "trx;LogFileName=test-results.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
deploy:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
proj: [Monitoring, Monitoring.Web]
defaults:
run:
working-directory: ./src
name: Update NuGet package - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Update project file version
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '(<Version>\d+\.\d+)\.(\d+)(<)'
replace: '$1.${{ github.run_number }}$3'
include: './Directory.Build.props'
- name: modifiedfiles
run: |
echo ${{ env.modifiedfiles }}
- name: print props
run: |
cat ./Directory.Build.props
# Force GeneratePackageOnBuild to false since dotnet pack does not build when
# it is true (https://github.com/dotnet/sdk/issues/10335)
- name: Build solution and generate NuGet package
run: |
dotnet pack './${{ env.PACKAGE_PROJECT_DIR }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' -c Release -o out /p:GeneratePackageOnBuild=false
# Skip duplicates since GPR does not support symbols in a separate nupkg file
- name: Push generated package to GitHub registry
run: dotnet nuget push ./out/*.nupkg --skip-duplicate