1
+ name : Continuous Integration
2
+
3
+ on : push
4
+
5
+ env :
6
+ Configuration : Release
7
+ ContinuousIntegrationBuild : true
8
+ DOTNET_CLI_TELEMETRY_OPTOUT : true
9
+ DOTNET_NOLOGO : true
10
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
11
+
12
+ jobs :
13
+ package :
14
+ runs-on : ubuntu-latest
15
+ permissions :
16
+ checks : write
17
+ name : Run tests and create NuGet package
18
+ outputs :
19
+ coverage-reports : ${{ steps.dotnet-test.outputs.coverage-reports }}
20
+ version : ${{ steps.dotnet-pack.outputs.version }}
21
+ nupkg-filename : ${{ steps.dotnet-pack.outputs.nupkg-filename }}
22
+ release-body : ${{ steps.tag-message.outputs.release-notes }}
23
+ steps :
24
+ - name : Checkout git repository
25
+ uses : actions/checkout@v2
26
+ with :
27
+ fetch-depth : 0
28
+
29
+ - name : Install .NET SDK
30
+ uses : actions/setup-dotnet@v1
31
+
32
+ - name : Retrieve cached NuGet packages
33
+ uses : actions/cache@v2
34
+ with :
35
+ path : ~/.nuget/packages
36
+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
37
+
38
+ - name : Restore NuGet packages
39
+ run : dotnet restore
40
+
41
+ - name : Build solution
42
+ run : dotnet build
43
+
44
+ - name : Run tests
45
+ run : dotnet test --no-build --logger "html;LogFileName=../../TestResults-${{ runner.os }}.html" --logger "trx;LogFileName=../../TestResults-${{ runner.os }}.trx" --logger GitHubActions
46
+ id : dotnet-test
47
+
48
+ - name : Upload received files from failing tests
49
+ uses : actions/upload-artifact@v2
50
+ if : failure()
51
+ with :
52
+ name : Received-${{ runner.os }}
53
+ path : " **/*.received.*"
54
+
55
+ - name : Upload test results
56
+ uses : actions/upload-artifact@v2
57
+ if : always()
58
+ with :
59
+ name : TestResults-${{ runner.os }}
60
+ path : TestResults-${{ runner.os }}.html
61
+
62
+ - name : Test Report
63
+ uses : dorny/test-reporter@v1
64
+ if : always()
65
+ with :
66
+ name : Test Results (${{ runner.os }})
67
+ path : TestResults-${{ runner.os }}.trx
68
+ reporter : dotnet-trx
69
+
70
+ - name : Create NuGet package
71
+ run : dotnet pack --no-build --output .
72
+ id : dotnet-pack
73
+
74
+ # - name: Upload NuGet package artifact
75
+ # if: matrix.os == 'macos-latest'
76
+ # uses: actions/upload-artifact@v2
77
+ # with:
78
+ # name: ${{ steps.dotnet-pack.outputs.nupkg-filename }}
79
+ # path: ${{ steps.dotnet-pack.outputs.nupkg-filename }}
80
+
81
+ - name : Retrieve tag message
82
+ if : matrix.os == 'macos-latest'
83
+ run : |
84
+ git fetch --tags --force
85
+ RELEASE_NOTES=$(git tag --list ${{ steps.dotnet-pack.outputs.version }} --format='%(contents)')
86
+ RELEASE_NOTES="${RELEASE_NOTES//'%'/%25}"
87
+ RELEASE_NOTES="${RELEASE_NOTES//$'\n'/%0A}"
88
+ RELEASE_NOTES="${RELEASE_NOTES//$'\r'/%0D}"
89
+ echo "::set-output name=release-notes::$RELEASE_NOTES"
90
+ id : tag-message
91
+
92
+ publish :
93
+ runs-on : ubuntu-latest
94
+ needs : package
95
+ if : startsWith(github.ref, 'refs/tags/')
96
+ name : Publish NuGet package and create GitHub release
97
+ steps :
98
+ - name : Download NuGet package artifact
99
+ uses : actions/download-artifact@v2
100
+ with :
101
+ name : ${{ needs.package.outputs.nupkg-filename }}
102
+
103
+ - name : Create GitHub Release
104
+ uses : actions/create-release@v1
105
+ env :
106
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107
+ with :
108
+ tag_name : ${{ needs.package.outputs.version }}
109
+ release_name : Version ${{ needs.package.outputs.version }}
110
+ body : ${{ needs.package.outputs.release-body }}
111
+ draft : false
112
+ prerelease : ${{ contains(needs.package.outputs.version, '-') }}
113
+
114
+ - name : Publish NuGet package on nuget.org
115
+ run : dotnet nuget push ${{ needs.package.outputs.nupkg-filename }} --source https://api.nuget.org/v3/index.json --api-key "${{ secrets.NUGET_API_KEY }}"
0 commit comments