-
Notifications
You must be signed in to change notification settings - Fork 1
234 lines (206 loc) · 8.38 KB
/
build.yml
File metadata and controls
234 lines (206 loc) · 8.38 KB
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
name: Build
on:
workflow_dispatch:
push:
branches:
- '**'
paths:
- 'src/**'
permissions:
actions: read
pages: write
id-token: write
contents: 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: [global-variables, 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:
project-path: '**/PolylineAlgorithm.csproj'
assembly-version: ${{ env.assembly-version }}
assembly-informational-version: ${{ env.assembly-informational-version }}
file-version: ${{ env.file-version }}
treat-warnins-as-error: ${{ needs.global-variables.outputs.is-release }}
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:
project-path: '**/PolylineAlgorithm.Tests.csproj'
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'
# 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: |
# 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 }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --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: ${{ needs.global-variables.outputs.is-release && !needs.global-variables.outputs.is-preview }}
name: Docs with docfx
needs: [global-variables, versioning, build]
env:
friendly-version: ${{ needs.versioning.outputs.friendly-version }}
is-release: ${{ needs.global-variables.outputs.is-release }}
is-preview: ${{ needs.global-variables.outputs.is-preview }}
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: 'Generate documentation'
uses: ./.github/actions/generate-docs
with:
artifact-name: 'docs'
docfx-json-manifest: './docfx/api-reference.json'
staging-directory: './docs/temp/**'
target-directory: './docs/${{ env.friendly-version }}/'
- name: 'Push documentation to docs branch'
uses: ./.github/actions/push-changes
with:
artifact-name: 'docs'
working-directory: './docs/${{ env.friendly-version }}/'
target-branch: 'docs'
commit-message: 'Update docs for version ${{ env.friendly-version }}'
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: './docs'
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4