-
Notifications
You must be signed in to change notification settings - Fork 8
377 lines (311 loc) · 12.1 KB
/
deploy-github-pages.yml
File metadata and controls
377 lines (311 loc) · 12.1 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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
name: Release Pipeline
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: release-pipeline
cancel-in-progress: true
env:
APP_TEST_PROJECT: tests/PrompterOne.Web.Tests/PrompterOne.Web.Tests.csproj
CORE_TEST_PROJECT: tests/PrompterOne.Core.Tests/PrompterOne.Core.Tests.csproj
PLAYWRIGHT_CLI: tests/PrompterOne.Web.UITests/bin/Debug/net10.0/.playwright/package/cli.js
SOLUTION_FILE: PrompterOne.slnx
jobs:
build_supporting_suites:
name: Build Supporting Tests
runs-on: macos-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Restore solution
run: dotnet restore "$SOLUTION_FILE"
- name: Restore WebAssembly workload
run: dotnet workload restore
- name: Build solution
run: dotnet build "$SOLUTION_FILE" -warnaserror
test_supporting_suites:
name: Supporting Tests
needs: build_supporting_suites
runs-on: macos-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Expose GitHub Actions Runtime
uses: actions/github-script@v8
with:
script: |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']);
core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']);
- name: Test supporting suites
run: |
dotnet test @./tests/dotnet-test-progress.rsp --project "$CORE_TEST_PROJECT" --coverage --coverage-output-format cobertura
dotnet test @./tests/dotnet-test-progress.rsp --project "$APP_TEST_PROJECT" --coverage --coverage-output-format cobertura
- name: Upload supporting suite test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-release-pipeline-supporting
path: |
tests/PrompterOne.Core.Tests/bin/**/TestResults/**
tests/PrompterOne.Web.Tests/bin/**/TestResults/**
if-no-files-found: ignore
- name: Publish supporting suite coverage report
if: always() && hashFiles('tests/PrompterOne.Core.Tests/bin/**/TestResults/*.cobertura.xml', 'tests/PrompterOne.Web.Tests/bin/**/TestResults/*.cobertura.xml') != ''
uses: ./.github/actions/publish-coverage-report
with:
artifact-name: coverage-report-release-pipeline-supporting
reports: tests/PrompterOne.Core.Tests/bin/**/TestResults/*.cobertura.xml;tests/PrompterOne.Web.Tests/bin/**/TestResults/*.cobertura.xml
targetdir: coverage-report/supporting
title: Release Pipeline Supporting Coverage
build_browser_suites:
name: Build Browser Tests
runs-on: macos-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Restore solution
run: dotnet restore "$SOLUTION_FILE"
- name: Restore WebAssembly workload
run: dotnet workload restore
- name: Build solution
run: dotnet build "$SOLUTION_FILE" -warnaserror
browser_tests:
name: ${{ matrix.suite.name }}
needs: build_browser_suites
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
suite:
- name: Shell
artifact: shell
project: tests/PrompterOne.Web.UITests.Shell/PrompterOne.Web.UITests.Shell.csproj
- name: Studio
artifact: studio
project: tests/PrompterOne.Web.UITests.Studio/PrompterOne.Web.UITests.Studio.csproj
- name: Editor
artifact: editor
project: tests/PrompterOne.Web.UITests.Editor/PrompterOne.Web.UITests.Editor.csproj
- name: Reader
artifact: reader
project: tests/PrompterOne.Web.UITests.Reader/PrompterOne.Web.UITests.Reader.csproj
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Expose GitHub Actions Runtime
uses: actions/github-script@v8
with:
script: |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']);
core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']);
- name: Restore solution
run: dotnet restore "$SOLUTION_FILE"
- name: Restore WebAssembly workload
run: dotnet workload restore
- name: Build solution
run: dotnet build "$SOLUTION_FILE" -warnaserror
- name: Install Playwright browser
run: node "$PLAYWRIGHT_CLI" install chromium
- name: Test browser suite
run: dotnet test @./tests/dotnet-test-progress.rsp --project "${{ matrix.suite.project }}" --coverage --coverage-output-format cobertura
- name: Upload browser suite test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-release-pipeline-${{ matrix.suite.artifact }}
path: tests/PrompterOne.Web.UITests.${{ matrix.suite.name }}/bin/**/TestResults/**
if-no-files-found: ignore
- name: Publish browser suite coverage report
if: always() && hashFiles(format('tests/PrompterOne.Web.UITests.{0}/bin/**/TestResults/*.cobertura.xml', matrix.suite.name)) != ''
uses: ./.github/actions/publish-coverage-report
with:
artifact-name: coverage-report-release-pipeline-${{ matrix.suite.artifact }}
reports: tests/PrompterOne.Web.UITests.${{ matrix.suite.name }}/bin/**/TestResults/*.cobertura.xml
targetdir: coverage-report/${{ matrix.suite.artifact }}
title: Release Pipeline ${{ matrix.suite.name }} Coverage
- name: Upload Playwright artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-artifacts-release-pipeline-${{ matrix.suite.artifact }}
path: output/playwright/
if-no-files-found: ignore
prepare_release:
name: Resolve Release Version
needs:
- test_supporting_suites
- browser_tests
runs-on: macos-latest
env:
APP_PROJECT: src/PrompterOne.Web/PrompterOne.Web.csproj
permissions:
contents: read
outputs:
release_tag: ${{ steps.release_version.outputs.release_tag }}
release_version: ${{ steps.release_version.outputs.release_version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Restore WebAssembly workload
run: dotnet workload restore
- name: Resolve release version
id: release_version
run: |
release_version="$(dotnet msbuild "$APP_PROJECT" -getProperty:VersionPrefix -p:PrompterOneBuildNumber=${{ github.run_number }} | tr -d '\r')"
release_tag="v${release_version}"
echo "release_version=$release_version" >> "$GITHUB_OUTPUT"
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
publish_release_build:
name: Publish Release Build
needs: prepare_release
runs-on: macos-latest
env:
APP_PROJECT: src/PrompterOne.Web/PrompterOne.Web.csproj
PAGES_ARTIFACT_ROOT: .artifacts/prompterone-pages
PAGES_BASE_PATH: /
PAGES_CNAME: app.prompter.one
PUBLISH_ROOT: .artifacts/prompterone-publish
RELEASE_ARCHIVE_NAME: prompterone-pages.zip
RELEASE_ARTIFACT_NAME: prompterone-release-package
RELEASE_ARTIFACT_ROOT: .artifacts/release-artifact
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Restore WebAssembly workload
run: dotnet workload restore
- name: Publish standalone WASM app
run: >
dotnet publish
"$APP_PROJECT"
-c Release
-o "$PUBLISH_ROOT"
-p:PrompterOneBuildNumber=${{ github.run_number }}
- name: Prepare GitHub Pages artifact
run: |
mkdir -p "$PAGES_ARTIFACT_ROOT"
cp -R "$PUBLISH_ROOT/wwwroot/." "$PAGES_ARTIFACT_ROOT/"
pages_index_path="$PAGES_ARTIFACT_ROOT/index.html"
pages_index_temp_path="$PAGES_ARTIFACT_ROOT/index.html.tmp"
sed "s#<base href=\"/\" />#<base href=\"${PAGES_BASE_PATH}\" />#g" "$pages_index_path" > "$pages_index_temp_path"
mv "$pages_index_temp_path" "$pages_index_path"
cp "$PAGES_ARTIFACT_ROOT/index.html" "$PAGES_ARTIFACT_ROOT/404.html"
printf '%s\n' "$PAGES_CNAME" > "$PAGES_ARTIFACT_ROOT/CNAME"
touch "$PAGES_ARTIFACT_ROOT/.nojekyll"
- name: Archive release bundle
run: |
mkdir -p "$RELEASE_ARTIFACT_ROOT"
cd "$PAGES_ARTIFACT_ROOT"
zip -r "$GITHUB_WORKSPACE/$RELEASE_ARTIFACT_ROOT/$RELEASE_ARCHIVE_NAME" .
- name: Upload GitHub release artifact
uses: actions/upload-artifact@v7
with:
name: ${{ env.RELEASE_ARTIFACT_NAME }}
path: ${{ env.RELEASE_ARTIFACT_ROOT }}/${{ env.RELEASE_ARCHIVE_NAME }}
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: ${{ env.PAGES_ARTIFACT_ROOT }}
publish_github_release:
name: Publish GitHub Release
needs:
- prepare_release
- publish_release_build
runs-on: macos-latest
env:
RELEASE_ARCHIVE_NAME: prompterone-pages.zip
RELEASE_ARTIFACT_NAME: prompterone-release-package
RELEASE_ARTIFACT_ROOT: .artifacts/release-artifact
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download release artifact
uses: actions/download-artifact@v8
with:
name: ${{ env.RELEASE_ARTIFACT_NAME }}
path: ${{ env.RELEASE_ARTIFACT_ROOT }}
- name: Resolve release asset path
id: release_asset
run: |
release_asset="$(find "$RELEASE_ARTIFACT_ROOT" -type f -name "$RELEASE_ARCHIVE_NAME" | head -n 1)"
if [ -z "$release_asset" ]; then
echo "Expected release archive '$RELEASE_ARCHIVE_NAME' was not found under '$RELEASE_ARTIFACT_ROOT'." >&2
exit 1
fi
echo "release_asset=$release_asset" >> "$GITHUB_OUTPUT"
- name: Create or update release tag and GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.prepare_release.outputs.release_tag }}
RELEASE_TITLE: PrompterOne ${{ needs.prepare_release.outputs.release_version }}
run: |
release_asset="${{ steps.release_asset.outputs.release_asset }}"
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" "$release_asset" --clobber
gh release edit "$RELEASE_TAG" --title "$RELEASE_TITLE"
else
gh release create "$RELEASE_TAG" "$release_asset" \
--title "$RELEASE_TITLE" \
--generate-notes \
--target "$GITHUB_SHA"
fi
deploy_github_pages:
name: Deploy GitHub Pages
needs:
- publish_release_build
- publish_github_release
runs-on: macos-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Configure GitHub Pages
uses: actions/configure-pages@v6
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5