-
Notifications
You must be signed in to change notification settings - Fork 14
151 lines (126 loc) · 5.33 KB
/
cd.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
name: Deploy to GitHub Pages
concurrency:
group: github-pages
cancel-in-progress: true
# Run workflow on every push to the master branch
on:
push:
branches: [ dev ]
paths-ignore:
- '**.md'
jobs:
deploy-to-github-pages:
# use ubuntu-latest image to run steps on
runs-on: ubuntu-latest
environment: github-pages
needs: demo-projects-build
steps:
# uses GitHub's checkout action to checkout code form the master branch
- uses: actions/checkout@v3
# sets up .NET Core SDK 7, 6
- name: Setup .NET 7, 6
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: src/Cropper.Blazor
- name: Build
run: dotnet build --no-restore
working-directory: src/Cropper.Blazor
- name: Test
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByAttribute='ExcludeFromCodeCoverage' /p:SkipAutoProps=true /p:Exclude="[*]Cropper.Blazor.Testing.*"
working-directory: src/Cropper.Blazor/Cropper.Blazor.UnitTests
- name: Coverage
uses: codecov/[email protected]
with:
file: coverage.net6.0.cobertura.xml
fail_ci_if_error: true
verbose: true
# publishes Blazor project to the release-folder
- name: Publish .NET Core Project
run: dotnet publish ./src/Cropper.Blazor/Server/Cropper.Blazor.Server.csproj -c Release --output release --nologo
# changes the base-tag in index.html from '/' to 'Cropper.Blazor' to match GitHub Pages repository subdirectory
#- name: Change base-tag in index.html from / to Cropper.Blazor
# run: sed -i 's/<base href="\/" \/>/<base href="\/Cropper.Blazor\/" \/>/g' release/wwwroot/index.html
- name: Fix service-worker-assets.js hashes
working-directory: release/wwwroot
run: |
jsFile=$(<service-worker-assets.js)
# remove JavaScript from contents so it can be interpreted as JSON
json=$(echo "$jsFile" | sed "s/self.assetsManifest = //g" | sed "s/;//g")
# grab the assets JSON array
assets=$(echo "$json" | jq '.assets[]' -c)
for asset in $assets
do
oldHash=$(echo "$asset" | jq '.hash')
#remove leading and trailing quotes
oldHash="${oldHash:1:-1}"
path=$(echo "$asset" | jq '.url')
#remove leading and trailing quotes
path="${path:1:-1}"
# shellcheck disable=2086
newHash="sha256-$(openssl dgst -sha256 -binary $path | openssl base64 -A)"
# shellcheck disable=2086
if [ $oldHash != $newHash ]; then
# escape slashes for json
# shellcheck disable=2001
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
# shellcheck disable=2001
newHash=$(echo "$newHash" | sed 's;/;\\/;g')
echo "Updating hash for $path from $oldHash to $newHash"
# escape slashes second time for sed
# shellcheck disable=2001
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
jsFile=$(echo -n "$jsFile" | sed "s;$oldHash;$newHash;g")
fi
done
echo -n "$jsFile" > service-worker-assets.js
# copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll
- name: Uploading files to gh-pages branch
uses: JamesIves/[email protected]
with:
token: ${{ secrets.DEPLOY_KEY }}
branch: gh-pages
folder: release/wwwroot
repository-name: CropperBlazor/CropperBlazor.github.io
demo-projects-build:
name: Build Demo Projects
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
# sets up .NET Core SDK 7, 6
- name: Setup .NET 7, 6
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install MAUI Workloads
run: |
dotnet workload install maui --ignore-failed-sources
- name: Restore dependencies for Cropper.Blazor.Demo
run: dotnet restore
working-directory: examples
- name: DotNet Build MVC with Blazor Server Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.MVC.With.Blazor.Server.Net7
- name: DotNet Build Blazor Server Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.Server.Net7
- name: DotNet Build Blazor MAUI Demo Project for .net 7
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.MAUI.Net7
- name: DotNet Build Blazor Server Demo Project for .net 6
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.Server.Net6
- name: DotNet Build Blazor MAUI Demo Project for .net 6
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.MAUI.Net6