-
Notifications
You must be signed in to change notification settings - Fork 0
299 lines (263 loc) · 10.9 KB
/
build.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: Build
on:
push:
branches:
- '**'
# paths:
# - 'src/**'
permissions:
actions: read
pages: write
id-token: write
concurrency:
group: build-${{ github.head_ref || github.ref }}
cancel-in-progress: false
env:
dotnet-sdk-version: '9.x'
build-configuration: 'Release'
build-platform: 'Any CPU'
git-version: '6.0.x'
test-result-directory: 'test-results'
nuget-packages-directory: 'nuget-packages'
jobs:
global-variables:
name: 'Global variables'
runs-on: ubuntu-latest
outputs:
github-run-id: ${{ github.run_id }}
github-run-number: ${{ github.run_number }}
is-release: ${{ startsWith(github.ref_name, 'release') }}
is-preview: ${{ startsWith(github.ref_name, 'preview') }}
steps:
- name: 'Global variables'
id: github
run: |
echo "github-run-id:${{ github.run_id }}"
echo "github-run-number:${{ github.run_number }}"
echo "is-release:${{ startsWith(github.ref_name, 'release') }}"
echo "is-preview:${{ startsWith(github.ref_name, 'preview') }}"
versioning:
name: Versioning with GitVersion
needs: [global-variables]
uses: ./.github/workflows/determine-version.yml
with:
config-file-path: './.gitversion/version.yml'
run-number: ${{ needs.global-variables.outputs.github-run-number }}
build:
name: Build with .NET
needs: [versioning]
runs-on: ubuntu-latest
env:
assembly-version: ${{ needs.versioning.outputs.assembly-version }}
assembly-informational-version: ${{ needs.versioning.outputs.assembly-informational-version }}
file-version: ${{ needs.versioning.outputs.file-version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
uses: actions/checkout@v4
- uses: ./.github/actions/build
with:
assembly-version: ${{ env.assembly-version }}
assembly-informational-version: ${{ env.assembly-informational-version }}
file-version: ${{ env.file-version }}
treat-warnins-as-error: ${{ env.is-release }}
search-glob-pattern: ${{ vars.SRC_DEFAULT_GLOB_PATTERN }}
test:
name: Test with .NET
needs: [build]
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
uses: actions/checkout@v4
- name: 'Setup .NET'
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-sdk-version }}
- uses: ./.github/actions/test
with:
test-project-glob-pattern: ${{ vars.TEST_DEFAULT_GLOB_PATTERN }}
test-results-directory: '${{ runner.temp }}/${{ env.test-result-directory }}/'
code-coverage-settings-file: '${{ github.workspace}}/code-coverage-settings.xml'
- uses: ./.github/actions/test-report
id: test-report
with:
test-result-folder: '${{ runner.temp }}/${{ env.test-result-directory }}/'
- name: Write test report summary
run: cat ${{ steps.test-report.outputs.test-report-file }} >> $GITHUB_STEP_SUMMARY
- uses: ./.github/actions/code-coverage
id: code-coverage-report
with:
test-result-folder: '${{ runner.temp }}/${{ env.test-result-directory }}/'
- name: Write code coverage report summary
run: cat ${{ steps.code-coverage-report.outputs.code-coverage-report-file }} >> $GITHUB_STEP_SUMMARY
pack:
name: Pack with .NET
needs: [versioning, build]
runs-on: ubuntu-latest
env:
assembly-version: ${{ needs.versioning.outputs.assembly-version }}
assembly-informational-version: ${{ needs.versioning.outputs.assembly-informational-version }}
file-version: ${{ needs.versioning.outputs.file-version }}
package-version: ${{ needs.versioning.outputs.package-version }}
package-artifact-name: package
outputs:
package-artifact-name: ${{ env.package-artifact-name }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-sdk-version }}
- name: Download Build
uses: actions/download-artifact@v4
with:
name: build
- name: Pack with .NET
run: |
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.package-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
- name: Upload Package
uses: actions/upload-artifact@v4
with:
name: ${{ env.package-artifact-name }}
path: |
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.nupkg
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.snupkg
publish-dev-package:
name: 'Publish'
uses: ./.github/workflows/release-nuget-package.yml
needs: [global-variables, pack]
secrets: inherit
with:
artifact-run-id: ${{ needs.global-variables.outputs.github-run-id }}
artifact-name: ${{ needs.pack.outputs.package-artifact-name }}
nuget-feed-server: 'AzureArtifacts'
environment: 'Development'
publish-production-package:
if: ${{ needs.global-variables.outputs.is-release == 'true' || needs.global-variables.outputs.is-preview == 'true' }}
name: 'Publish'
uses: ./.github/workflows/release-nuget-package.yml
needs: [global-variables, pack]
secrets: inherit
with:
artifact-run-id: ${{ needs.global-variables.outputs.github-run-id }}
artifact-name: ${{ needs.pack.outputs.package-artifact-name }}
nuget-feed-server: 'NuGet'
environment: 'NuGet'
# benchmark:
# if: ${{ github.env.is_release || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }}
# name: Benchmark with .NET CLI on ${{ matrix.os }}
# needs: [build]
# strategy:
# matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
# runs-on: ${{ matrix.os }}
# steps:
# - name: 'Checkout ${{ github.head_ref || github.ref }}'
# uses: actions/checkout@v4
# - name: Install .NET SDK
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: |
# 6.x
# 8.x
# 9.x
# - name: Download Build
# uses: actions/download-artifact@v4
# with:
# name: build
# - name: Benchmark
# working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
# run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --exporters GitHub --memory --artifacts ${{ runner.temp }}/benchmarks/ --join
# - name: Upload Benchmark Results
# uses: actions/upload-artifact@v4
# with:
# name: benchmark-${{ matrix.os }}
# path: |
# ${{ runner.temp }}/benchmarks/**/*-report-github.md
# - name: Write Benchmark Summary
# shell: bash
# run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY
# working-directory: ${{ runner.temp }}/benchmarks/
# publish-docs:
# if: ${{ github.env.is_release && !github.env.is_preview }}
# name: Docs with docfx
# needs: [benchmark, test]
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: ubuntu-latest
# steps:
# - name: 'Checkout ${{ github.head_ref || github.ref }}'
# uses: actions/checkout@v4
# - name: Dotnet Setup
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: ${{ env.dotnet-sdk-version }}
# - name: Download Benchmarks
# uses: actions/download-artifact@v4
# with:
# pattern: benchmark-*
# path: ${{ runner.temp }}/benchmarks/
# merge-multiple: false
# - run: |
# echo -e '\n## Windows' >> ${{ github.workspace}}/docfx/benchmarks/index.md
# cat benchmark-windows-latest/**/*.md >> ${{ github.workspace}}/docfx/benchmarks/index.md
# echo -e '\n## Linux' >> ${{ github.workspace}}/docfx/benchmarks/index.md
# cat benchmark-ubuntu-latest/**/*.md >> ${{ github.workspace}}/docfx/benchmarks/index.md
# echo -e '\n## macOS' >> ${{ github.workspace}}/docfx/benchmarks/index.md
# cat benchmark-macos-latest/**/*.md >> ${{ github.workspace}}/docfx/benchmarks/index.md
# working-directory: ${{ runner.temp }}/benchmarks/
# - run: dotnet tool update -g docfx
# - run: docfx ./docfx/docfx.json
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v4
# with:
# path: './docs'
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4
# publish-package-internal:
# if: ${{ !github.env.is_release }}
# name: Publish package with .NET CLI
# needs: [pack]
# environment:
# name: private-nuget-feed
# runs-on: ubuntu-latest
# steps:
# - name: 'Checkout ${{ github.head_ref || github.ref }}'
# uses: actions/checkout@v4
# - name: Dotnet Setup
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: ${{ env.dotnet-sdk-version }}
# - name: Download Packages
# uses: actions/download-artifact@v4
# with:
# name: package
# path: ${{ runner.temp }}/packages/
# - run: |
# dotnet nuget add source ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_URL }} --name private-feed --username username --password ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }} --store-password-in-clear-text
# dotnet nuget push **/*.nupkg --source private-feed --api-key ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }}
# working-directory: ${{ runner.temp }}/packages/
# release-package:
# if: ${{ github.env.is_release }}
# name: Release package with .NET CLI
# needs: [pack, test]
# environment:
# name: public-nuget-feed
# runs-on: ubuntu-latest
# steps:
# - name: 'Checkout ${{ github.head_ref || github.ref }}'
# uses: actions/checkout@v4
# - name: Dotnet Setup
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: ${{ env.dotnet-sdk-version }}
# - name: Download Packages
# uses: actions/download-artifact@v4
# with:
# name: package
# path: ${{ runner.temp }}/packages/
# - run: |
# dotnet nuget push **/*.nupkg --source ${{ vars.PUBLIC_NUGET_PACKAGE_FEED_URL }} --api-key ${{ secrets.PUBLIC_NUGET_PACKAGE_FEED_API_KEY }}
# working-directory: ${{ runner.temp }}/packages/