-
-
Notifications
You must be signed in to change notification settings - Fork 0
222 lines (182 loc) · 5.93 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
# SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
#
# SPDX-License-Identifier: MIT
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: read
checks: write
pull-requests: write
actions: write
jobs:
lookup-runtime-caches:
runs-on: ubuntu-latest
outputs:
linux-x64: ${{ steps.lookup-linux-x64.outputs.cache-hit }}
win-x64: ${{ steps.lookup-win-x64.outputs.cache-hit }}
osx-arm64: ${{ steps.lookup-osx-arm64.outputs.cache-hit }}
browser-wasm: ${{ steps.lookup-browser-wasm.outputs.cache-hit }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Lookup linux-x64
id: lookup-linux-x64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: linux-x64
- name: Lookup win-x64
id: lookup-win-x64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: win-x64
- name: Lookup osx-arm64
id: lookup-osx-arm64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: osx-arm64
- name: Lookup browser-wasm
id: lookup-browser-wasm
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: browser-wasm
runtime-linux-x64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.linux-x64 }}
uses: ./.github/workflows/runtime-linux-x64.yml
permissions:
contents: read
actions: write
runtime-win-x64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.win-x64 }}
uses: ./.github/workflows/runtime-win-x64.yml
permissions:
contents: read
actions: write
runtime-osx-arm64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.osx-arm64 }}
uses: ./.github/workflows/runtime-osx-arm64.yml
permissions:
contents: read
actions: write
runtime-browser-wasm:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.browser-wasm }}
uses: ./.github/workflows/runtime-browser-wasm.yml
permissions:
contents: read
actions: write
build:
needs:
- runtime-linux-x64
- runtime-win-x64
- runtime-osx-arm64
- runtime-browser-wasm
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore linux-x64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: linux-x64
- name: Restore win-x64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: win-x64
- name: Restore osx-arm64
uses: ./.github/actions/restore-runtime-cache
with:
runtime: osx-arm64
- name: Restore browser-wasm
uses: ./.github/actions/restore-runtime-cache
with:
runtime: browser-wasm
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json', '.config/dotnet-tools.json', '**/Directory.Packages.props') }}
- name: Restore dependencies
run: |
dotnet tool restore
dotnet workload restore
dotnet restore
dotnet restore Documentation --no-dependencies
- name: Build
run: |
dotnet build --configuration Release --no-restore
- name: Test
run: |
dotnet test --configuration Release --no-build \
-p:TestingPlatformCommandLineArguments="--report-trx --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml"
- name: Package
run: |
dotnet pack --configuration Release --no-build
- name: Upload Package Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: |
**/*.nupkg
**/*.snupkg
retention-days: 14
- name: Publish WebAssembly example
# This one is *slow*, so only when commiting to main (and deploying GitHub Pages)
if: github.event_name != 'pull_request'
run: |
dotnet publish --configuration Release --no-restore
- name: Build Documentation
run: |
dotnet build --configuration Release --no-restore Documentation
- name: Upload GitHub Pages as artifact
uses: actions/upload-pages-artifact@v3
with:
path: Documentation/_site/
- name: Convert test results
if: ${{ !cancelled() }}
run: |
find . -name "*.trx" -exec dotnet tool run trx2junit --output TestResults/JUnit {} +
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: TestResults/JUnit/*.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
needs: build
if: ${{ always() && github.event_name == 'push' && needs.build.result == 'success' }}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4