-
Notifications
You must be signed in to change notification settings - Fork 32
627 lines (522 loc) Β· 24.2 KB
/
GithubActionsWIP.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
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
ο»Ώname: GithubActionsWIP
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
buildPlatform: 'Any CPU'
buildConfiguration: 'WebAssembly'
outputDocFx: ${{github.workspace}}\siteDocFx
outputMB: ${{github.workspace}}/siteMB
outputWeb: ${{github.workspace}}/siteWeb
projectMB: 'Material.Blazor/Material.Blazor.csproj'
projectTest: 'Material.Blazor.Test/Material.Blazor.Test.csproj'
projectWeb: 'Material.Blazor.Website.WebAssembly/Material.Blazor.Website.WebAssembly.csproj'
materialBlazorMD3LibModule: 'Material.Blazor.MD3/wwwroot/Material.Blazor.MD3.lib.module.js'
outputDocFxMD3: ${{github.workspace}}\siteDocFxMD3
outputMBMD3: ${{github.workspace}}/siteMBMD3
outputWebMD3: ${{github.workspace}}/siteWebMD3
projectMBMD3: 'Material.Blazor.MD3/Material.Blazor.MD3.csproj'
projectWebMD3: 'Material.Blazor.Website.WebAssembly.MD3/Material.Blazor.Website.WebAssembly.MD3.csproj'
jobs:
############################################################################################################
# These jobs are used to gate actions. By creating these jobs we don't need to proliferate the repo checks
############################################################################################################
build-allowed:
name: Build allowed
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Nothing to see here
run: echo ""
build-allowed-fork:
name: Allow build only on M-B/M.B
needs: [build-allowed]
runs-on: ubuntu-latest
if: (github.repository != 'Material-Blazor/Material.Blazor')
steps:
- name: Nothing to see here
run: echo ""
deployment-allowed-mb:
name: Allow deployment on M-B/M.B
needs: [build-allowed]
runs-on: ubuntu-latest
if: (github.repository == 'Material-Blazor/Material.Blazor')
steps:
- name: Nothing to see here
run: echo ""
############################################################################################################
# Set unified version
############################################################################################################
set-unified-version:
name: Create the date based version
needs: [deployment-allowed-mb]
runs-on: ubuntu-latest
outputs:
unifiedVersion: ${{ steps.setVersion.outputs.version }}
steps:
- id: setVersion
run: echo "version=5.0.0-wip.$(date +'%Y-%m-%d--%H-%M-%S')" >> $GITHUB_OUTPUT
shell: bash
############################################################################################################
# Run the test project. Should this fail, the build & deploy steps are skipped
############################################################################################################
test:
name: Run .NET tests
runs-on: windows-latest
needs: [build-allowed]
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Run the acceptance tests as the first build action and cancel out the rest if it fails
run: dotnet test ${{env.projectTest}} --configuration ${{env.buildConfiguration}}
############################################################################################################
# Build documentation
############################################################################################################
build-documentation:
name: Build documentation
runs-on: windows-latest
needs: [build-allowed]
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Setup docfx
run: |
copy Material.Blazor\docfx.json.MD2 docfx.json
copy Material.Blazor\index.md.MD2 index.md
copy Material.Blazor\toc.yml.MD2 toc.yml
dotnet tool update -g docfx
- name: Build Material.Blazor
run: dotnet build ${{env.projectMB}} --configuration ${{env.buildConfiguration}}
- name: Create documentation π§
run: docfx docfx.json
env:
DOCFX_SOURCE_BRANCH_NAME: main
- name: Show the documentation artifacts
run: dir siteDocFx
- name: Upload Documentation Artifacts πΊ # The documentation site is then uploaded as an artifact named 'siteDocFx'.
uses: actions/upload-artifact@v4
with:
name: siteDocFx
path: siteDocFx
############################################################################################################
# Build website
############################################################################################################
build-website:
name: Build website
needs: [test, set-unified-version]
runs-on: windows-latest
steps:
- name: Set ciVersion as env variable
run: echo "ciVersion=${{needs.set-unified-version.outputs.unifiedVersion}}" >> $GITHUB_ENV
shell: bash
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Build & Publish Website π§
run: >
dotnet publish ${{env.projectWeb}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputWeb}}
-p:Version=${{env.ciVersion}}
-p:BlazorEnableCompression=false
--framework net8.0
# All of the trace was added to show that .js & .min.js files were getting created but not
# being included in the published content. This was a result of VS 'helpfully' adding some
# 'content none' and 'content remove' directives after a deletion of the .js files to test
# the build of derived files. It is being left in place to help in the future.
# - name: Display workspace κͺ
# run: dir ${{github.workspace}}
- name: Display wwwroot κͺ
run: dir ${{github.workspace}}/Material.Blazor/wwwroot
# - name: Display MaterialBlazor package output κͺ
# run: dir ${{env.outputWeb}}
# - name: Display MaterialBlazor package output wwwroot κͺ
# run: dir ${{env.outputWeb}}/wwwroot
# - name: Display MaterialBlazor package output wwwroot/_content κͺ
# run: dir ${{env.outputWeb}}/wwwroot/_content
- name: Display MaterialBlazor package output wwwroot/_content κͺ
run: dir ${{env.outputWeb}}/wwwroot/_content/Material.Blazor
- name: Upload Website Artifacts πΊ # The website is then uploaded as an artifact named 'siteWeb'.
uses: actions/upload-artifact@v4
with:
name: siteWeb
path: siteWeb
############################################################################################################
# Build nuget package
############################################################################################################
build-package:
name: Build nuget package
needs: [test, set-unified-version]
runs-on: windows-latest
steps:
- name: Set ciVersion as env variable
run: echo "ciVersion=${{needs.set-unified-version.outputs.unifiedVersion}}" >> $GITHUB_ENV
shell: bash
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Build Material.Blazor & Generate the NuGet package π§
run: >
dotnet pack ${{env.projectMB}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputMB}}
-p:IncludeSymbols=true
-p:SymbolPackageFormat=snupkg
-p:Version=${{env.ciVersion}}
- name: Display MaterialBlazor package output κͺ
run: dir ${{env.outputMB}}
############################################################################################################
# deployghpages-mbcurrent
# The current version of Material.Blazor is viewable on GH-pages in addition to material-blazor.com
############################################################################################################
deployghpages-mbcurrent:
name: Deploy to GitHub pages (Material-Blazor/Material.Blazor.Current)
needs: [test, build-documentation, build-website, deployment-allowed-mb]
runs-on: ubuntu-latest
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Download Artifacts π» # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: siteDocFx
path: siteDocFx
- name: Download Artifacts π» # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: siteWeb
path: siteWeb
- name: Configure deployment directory structure κͺ
run: mv siteWeb/wwwroot deployroot; mv siteDocFx deployroot/docs
# this step rewrites the base href when we are in the main repo and about to deploy to the Material.Blazor.Current repo
- name: Base Href Rewrite π
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: 'deployroot/index.html'
base_href: '/Material.Blazor.Current/'
# this step deploys to Material-Blazor/Material.Blazor.Current when we are in the main repo
- name: Deploy π
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{secrets.GH_PAT}}
branch: gh-pages
folder: 'deployroot'
repository-name: Material-Blazor/Material.Blazor.Current
############################################################################################################
# comparison
############################################################################################################
# compare:
# needs: [deployghpages, test]
# name: Compare pages
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
# uses: actions/checkout@v4
# - id: install-puppeteer
# run: |
# npm i puppeteer trim-image looks-same glob
# - id: test
# run: |
# node Material.Blazor.Test/comparison.js https://${{github.repository_owner}}.github.io/Material.Blazor > comparison.log
# # A few things need to be ignored to make a sensible comparison:
# # some files have integrity hashes. Those change often, so ignore those
# # many elements have GUIDs as attributes etc. GUIDs are usually generated dynamically, so differ on each page render
# # tooltips have ids too, in the format mb-tooltip-123
# - name: normalize
# run: |
# sed -i 's/integrity="\(.*\)"/integrity="..."/g' *.html
# sed -i 's/[a-f0-9]\{8\}-[a-f0-9]\{4\}-[a-f0-9]\{4\}-[a-f0-9]\{4\}-[a-f0-9]\{12\}/guid/g' *.html
# sed -i 's/mb-tooltip-[0-9]*/mb-tooltip-id/g' *.html
# sed -i 's/b-[0-9a-z]*/b-id/g' *.html
# sed -i 's/_bl_[0-9]*/_bl_id/g' *.html
# sed -i 's/<strong>.*-ci..*<\/strong>//' *.html
# sed -i 's/base href.*//' *.html
# # We only want to see the differences, so we run diff with -d
# # We also don't want to be notified of whitespace-only changes, so we ignore those with -w
# # The exit code of diff is non-zero when there is a non-empty difference, but we need to continue running this job regardless
# - name: diff
# run: |
# for file in $(find -type f -name 'mb_*.html')
# do
# suffix=$(echo $file | cut -c5-)
# echo "### Differences on page '${suffix}'" > report${suffix}.md
# echo "\`\`\`diff" >> report${suffix}.md
# diff -d -w mb${suffix} fork${suffix} >> report${suffix}.md || true
# echo "\`\`\`" >> report${suffix}.md
# done
# - name: Aggregate reports
# run: |
# echo "# Comparison report" > all_reports.md
# echo "Number of pages compared:" >> all_reports.md
# ls -a -1 report*md | wc -l >> all_reports.md
# cat report*md >> all_reports.md
# - name: Summarise report for auto-generated issue
# run: |
# echo "# Number of pages compared:" > meta_report.md
# ls -a -1 report*md | wc -l >> meta_report.md
# echo "" >> meta_report.md
# echo "# Pages with some difference:" >> meta_report.md
# wc -l report*md | sed '$d' | grep -v " 3 " | rev | cut -d' ' -f1 | rev | sed 's%report\(.*\).md%\1%' >> meta_report.md
# echo "" >> meta_report.md
# echo "# Pages without differences:" >> meta_report.md
# wc -l report*md | sed '$d' | grep " 3 " | rev | cut -d' ' -f1 | rev | sed 's%report\(.*\).md%\1%' >> meta_report.md
# echo "" >> meta_report.md
# echo "# Preview of differences:" >> meta_report.md
# wc -l report*md | sed '$d' | grep -v " 3 " | rev | cut -d' ' -f1 | rev | xargs cat >> meta_report.md
# # At this point we have the full differences in the meta report. This might be too large! We truncate, if necessary:
# if [ $(wc -c meta_report.md | cut -d ' ' -f 1) -lt 65536 ];
# then
# echo "Report is small enough"
# else
# echo "" >> tail.md
# echo "" >> tail.md
# echo "The full report is available as artifact on https://github.com/${{github.actor}}/Material.Blazor/actions/runs/${{github.run_id}}" >> tail.md
# remaining_bytes=$((65536-$(wc -c tail.md | cut -d ' ' -f1)))
# dd if=meta_report.md of=trimmed_meta_report.md bs=1 count=$remaining_bytes
# cat trimmed_meta_report.md tail.md > meta_report.md
# fi
# - name: Upload comparison & report artifact
# uses: actions/upload-artifact@v4
# with:
# name: comparison_report
# path: |
# comparison.log
# *.html
# *.png
# report*.md
# all_reports.md
# - name: Create issue from file
# uses: peter-evans/create-issue-from-file@v4
# with:
# title: Comparison of material-blazor.github.io/Material.Blazor.Current and ${{github.actor}}.github.io/Material.Blazor
# content-filepath: meta_report.md
# labels: report, automated issue
# token: ${{secrets.GH_PAT}}
############################################################################################################
# Build only nuget package
############################################################################################################
build-only-package:
name: Build nuget package
needs: [test, build-allowed-fork]
runs-on: windows-latest
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Build Material.Blazor & Generate the NuGet package π§
run: >
dotnet pack ${{env.projectMB}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputMB}}
-p:IncludeSymbols=true
-p:SymbolPackageFormat=snupkg
- name: Display MaterialBlazor package output κͺ
run: dir ${{env.outputMB}}
############################################################################################################
############################################################################################################
############################################################################################################
# MD3 jobs
############################################################################################################
############################################################################################################
############################################################################################################
############################################################################################################
# Build documentation
############################################################################################################
build-documentation-MD3:
name: Build documentation
runs-on: windows-latest
needs: [build-allowed]
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Setup docfx
run: |
copy Material.Blazor.MD3\docfx.json.MD3 docfx.json
copy Material.Blazor.MD3\index.md.MD3 index.md
copy Material.Blazor.MD3\toc.yml.MD3 toc.yml
dotnet tool update -g docfx
- name: Build Material.Blazor
run: dotnet build ${{env.projectMBMD3}} --configuration ${{env.buildConfiguration}}
- name: Create documentation π§
run: docfx docfx.json
env:
DOCFX_SOURCE_BRANCH_NAME: main
- name: Show the documentation artifacts
run: dir siteDocFxMD3
- name: Upload Documentation Artifacts πΊ # The project is then uploaded as an artifact named 'siteDocFx'.
uses: actions/upload-artifact@v4
with:
name: siteDocFxMD3
path: siteDocFxMD3
###########################################################################################################
# Build website
############################################################################################################
build-website-MD3:
name: Build website MD3
needs: [test, set-unified-version]
runs-on: windows-latest
steps:
- name: Set ciVersion as env variable
run: echo "ciVersion=${{needs.set-unified-version.outputs.unifiedVersion}}" >> $GITHUB_ENV
shell: bash
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
# - name: Display wwwroot M.B.W.MD3
# run: dir ${{github.workspace}}/Material.Blazor.Website.MD3/wwwroot
# - name: Display wwwroot/icons M.B.W.MD3
# run: dir ${{github.workspace}}/Material.Blazor.Website.MD3/wwwroot/icons
# - name: Display wwwroot/images M.B.W.MD3
# run: dir ${{github.workspace}}/Material.Blazor.Website.MD3/wwwroot/images
- name: Build & Publish Website π§
run: >
dotnet publish ${{env.projectWebMD3}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputWebMD3}}
-p:Version=${{env.ciVersion}}
-p:BlazorEnableCompression=false
--framework net8.0
# All of the trace was added to show that .js & .min.js files were getting created but not
# being included in the published content. This was a result of VS 'helpfully' adding some
# 'content none' and 'content remove' directives after a deletion of the .js files to test
# the build of derived files. It is being left in place to help in the future.
# - name: Display workspace κͺ
# run: dir ${{github.workspace}}
# - name: Display wwwroot M.B.MD3
# run: dir ${{github.workspace}}/Material.Blazor.MD3/wwwroot
# - name: Display wwwroot M.B.W.MD3
# run: dir ${{github.workspace}}/Material.Blazor.Website.MD3/wwwroot
# - name: Display MaterialBlazorMD3 package output κͺ
# run: dir ${{env.outputWebMD3}}
# - name: Display MaterialBlazorMD3 package output wwwroot κͺ
# run: dir ${{env.outputWebMD3}}/wwwroot
# - name: Display MaterialBlazorMD3 package output wwwroot _content κͺ
# run: dir ${{env.outputWebMD3}}/wwwroot/_content
# - name: Display MaterialBlazorMD3 package output wwwroot _content Material.Blazor.MD3 κͺ
# run: dir ${{env.outputWebMD3}}/wwwroot/_content/Material.Blazor.MD3
- name: Upload Website Artifacts πΊ # The website is then uploaded as an artifact named 'siteWeb'.
uses: actions/upload-artifact@v4
with:
name: siteWebMD3
path: siteWebMD3
############################################################################################################
# Build nuget package
############################################################################################################
build-package-MD3:
name: Build nuget package MD3
needs: [test, set-unified-version]
runs-on: windows-latest
steps:
- name: Set ciVersion as env variable
run: echo "ciVersion=${{needs.set-unified-version.outputs.unifiedVersion}}" >> $GITHUB_ENV
shell: bash
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Build Material.Blazor & Generate the NuGet package π§
run: >
dotnet pack ${{env.projectMBMD3}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputMBMD3}}
-p:IncludeSymbols=true
-p:SymbolPackageFormat=snupkg
-p:Version=${{env.ciVersion}}
- name: Display MaterialBlazor package output κͺ
run: dir ${{env.outputMBMD3}}
- name: Compute the SHA256 hash of material.blazor.md3.lib.module.js
shell: pwsh
run: |
.\computesha.ps1 ${{env.materialBlazorMD3LibModule}}
############################################################################################################
# deployghpages-mbcurrent
# The current version of Material.Blazor is viewable on GH-pages in addition to material-blazor.com
############################################################################################################
deployghpages-mbcurrent-MD3:
name: Deploy to GitHub pages (Material-Blazor/Material.Blazor.MD3.Current)
needs: [test, build-website-MD3, build-documentation-MD3, deployment-allowed-mb]
runs-on: ubuntu-latest
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Download Artifacts π» # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: siteDocFxMD3
path: siteDocFxMD3
- name: Download Artifacts π» # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: siteWebMD3
path: siteWebMD3
- name: Configure deployment directory structure κͺ
run: mv siteWebMD3/wwwroot deployroot; mv siteDocFxMD3 deployroot/docs
# this step rewrites the base href when we are in the main repo and about to deploy to the Material.Blazor.Current repo
- name: Base Href Rewrite π
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: 'deployroot/index.html'
base_href: '/Material.Blazor.MD3.Current/'
# this step deploys to Material-Blazor/Material.Blazor.MD3.Current when we are in the main repo
- name: Deploy π
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{secrets.GH_PAT}}
branch: gh-pages
folder: 'deployroot'
repository-name: Material-Blazor/Material.Blazor.MD3.Current
############################################################################################################
# Build only MD3 nuget package
############################################################################################################
build-only-package-MD3:
name: Build nuget package MD3
needs: [test, build-allowed-fork]
runs-on: windows-latest
steps:
- name: Checkout repository under $GITHUB_WORKSPACE so the job can access it ποΈ
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Build Material.Blazor & Generate the NuGet package π§
run: >
dotnet pack ${{env.projectMBMD3}}
--configuration ${{env.buildConfiguration}}
--output ${{env.outputMBMD3}}
-p:IncludeSymbols=true
-p:SymbolPackageFormat=snupkg
- name: Display MaterialBlazor package output κͺ
run: dir ${{env.outputMBMD3}}