-
Notifications
You must be signed in to change notification settings - Fork 3
255 lines (210 loc) · 9.07 KB
/
ci.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: CI
on:
# Trigger the workflow on push or pull request,
# for any branch or version tag
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Resolve project name
shell: pwsh
run: Add-Content -Path ${env:GITHUB_ENV} "`nprojectName=$(${env:GITHUB_REPOSITORY}.substring(${env:GITHUB_REPOSITORY}.IndexOf('/') + 1))" -Encoding utf8
- name: Checkout
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v3.0.0
with:
useConfigFile: true
configFilePath: ./GitVersion.yml
- name: Update project version
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6
with:
projectFilter: 'package.props'
version: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }}
fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }}
informationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
- name: Setup dotnet v6.0
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '6.0.x' # SDK Version to use.
- name: Download snk file
run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > Neovolve.Logging.Xunit.snk
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
- name: Generate coverage report
# run: reportgenerator -reports:**/coverage.cobertura.xml -targetdir:Report -reporttypes:HtmlInline_AzurePipelines;Cobertura
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.8
with:
reports: "**/coverage*cobertura.xml"
targetdir: "Report"
reporttypes: "HtmlInline;Cobertura"
tag: '${{ github.run_number }}_${{ github.run_id }}'
# Don't run on fork or dependabot builds
if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]'
- name: Publish coverage report
uses: 5monkeys/cobertura-action@master
with:
path: Report/Cobertura.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
minimum_coverage: 75
# Don't run on fork or dependabot builds
if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]'
- name: Pack
run: dotnet pack -c Release --no-build --include-symbols -o $GITHUB_WORKSPACE/staging
- name: Publish build artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: staging
- shell: bash
name: Write version
run: |
echo '${{ steps.gitversion.outputs.NuGetVersionV2 }}' > version.txt
- name: Upload version
uses: actions/upload-artifact@v4
with:
name: version
path: version.txt
publish:
needs: build
runs-on: ubuntu-latest
# Only run on pushes which should only be on the base repository
if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.actor != 'dependabot[bot]'
steps:
- name: Resolve project name
shell: pwsh
run: Add-Content -Path ${env:GITHUB_ENV} "`nprojectName=$(${env:GITHUB_REPOSITORY}.substring(${env:GITHUB_REPOSITORY}.IndexOf('/') + 1))" -Encoding utf8
- name: Download version
uses: actions/download-artifact@v4
with:
name: version
- name: Read version
shell: bash
run: |
value=`cat version.txt`
echo NuGetVersionV2=$(echo $value) >> $GITHUB_ENV
- name: Download packages
uses: actions/download-artifact@v4
with:
name: packages
- name: Setup nuget
uses: nuget/setup-nuget@v2
- name: Download version
uses: actions/download-artifact@v4
with:
name: version
- name: Read version
shell: bash
run: |
value=`cat version.txt`
echo NuGetVersionV2=$(echo $value) >> $GITHUB_ENV
- name: Publish package to MyGet.org
env:
MYGET_APIKEY: ${{ secrets.MYGET_APIKEY }}
run: nuget push ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.symbols.nupkg $MYGET_APIKEY -source https://www.myget.org/F/neovolve/api/v2/package
- name: Publish signed package to MyGet.org
env:
MYGET_APIKEY: ${{ secrets.MYGET_APIKEY }}
run: nuget push ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.symbols.nupkg $MYGET_APIKEY -source https://www.myget.org/F/neovolve/api/v2/package
release:
needs: build
runs-on: ubuntu-latest
# Only run on pushes which should only be on the base repository and only where the branch is main or is a version tagged build
if: (github.event_name == 'push' || github.event_name == 'pull_request') && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.actor != 'dependabot[bot]'
steps:
- name: Resolve project name
shell: pwsh
run: Add-Content -Path ${env:GITHUB_ENV} "`nprojectName=$(${env:GITHUB_REPOSITORY}.substring(${env:GITHUB_REPOSITORY}.IndexOf('/') + 1))" -Encoding utf8
- name: Download version
uses: actions/download-artifact@v4
with:
name: version
- name: Read version
shell: bash
run: |
value=`cat version.txt`
echo NuGetVersionV2=$(echo $value) >> $GITHUB_ENV
- name: Download packages
uses: actions/download-artifact@v4
with:
name: packages
- name: Setup nuget
uses: nuget/setup-nuget@v2
- name: Publish package to GitHub
run: nuget push ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.symbols.nupkg ${{ secrets.GITHUB_TOKEN }} -source "https://nuget.pkg.github.com/roryprimrose/index.json"
- name: Publish signed package to GitHub
run: nuget push ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.symbols.nupkg ${{ secrets.GITHUB_TOKEN }} -source "https://nuget.pkg.github.com/roryprimrose/index.json"
- name: Publish package to NuGet.org
env:
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
run: nuget push ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.symbols.nupkg $NUGET_APIKEY -source https://api.nuget.org/v3/index.json
- name: Publish signed package to NuGet.org
env:
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
run: nuget push ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.symbols.nupkg $NUGET_APIKEY -source https://api.nuget.org/v3/index.json
- name: Create release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NuGetVersionV2 }}
release_name: Release ${{ env.NuGetVersionV2 }}
draft: false
prerelease: ${{ contains(env.NuGetVersionV2, 'beta') }}
- name: Upload release asset for package
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.nupkg
asset_name: ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.nupkg
asset_content_type: application/zip
- name: Upload release asset for symbol package
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.symbols.nupkg
asset_name: ${{ env.projectName }}.${{ env.NuGetVersionV2 }}.symbols.nupkg
asset_content_type: application/zip
- name: Upload release asset for signed package
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.nupkg
asset_name: ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.nupkg
asset_content_type: application/zip
- name: Upload release asset for signed symbol package
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.symbols.nupkg
asset_name: ${{ env.projectName }}.Signed.${{ env.NuGetVersionV2 }}.symbols.nupkg
asset_content_type: application/zip