Skip to content

5.3.11 (#1342)

5.3.11 (#1342) #2240

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'
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@v4
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@v4
with:
dotnet-version: '8.x'
- name: Setup docfx
run: 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 site artifacts
run: dir .artifacts/siteDocFx
- name: Show the documentation site api artifacts
run: dir .artifacts/siteDocFx/.artifacts/api
- name: Upload Documentation Artifacts 🔺 # The documentation site is then uploaded as an artifact named 'siteDocFx'.
uses: actions/upload-artifact@v4
with:
name: siteDocFx
include-hidden-files: true
path: .artifacts/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@v4
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@v4
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 siteDocFx🔻 # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: siteDocFx
path: siteDocFx
- name: Show the documentation site artifacts
run: dir siteDocFx
- name: Show the documentation site api artifacts
run: dir siteDocFx/.artifacts/api
- name: Download Artifacts siteWeb🔻 # 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
- name: Show the documentation site api artifacts on deployroot
run: dir 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@v4
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}}