forked from CropperBlazor/Cropper.Blazor
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (160 loc) · 6.69 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
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
name: Deploy to GitHub Pages
concurrency:
group: github-pages
cancel-in-progress: true
on:
push:
branches: [ dev ]
paths-ignore:
- '**.md'
jobs:
code-quality-check:
name: Check code quality
uses: CropperBlazor/Cropper.Blazor/.github/workflows/build-test-template.yml@dev
secrets: inherit
deploy-to-github-pages:
runs-on: ubuntu-latest
environment: github-pages
needs: [code-quality-check, demo-projects-build]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore dependencies
run: dotnet restore
working-directory: src/Cropper.Blazor
- name: Restore dotnet tool
run: dotnet tool restore
working-directory: src/Cropper.Blazor/Cropper.Blazor
- name: Wait for Exit Code 0 for Cropper.Blazor.Sitemap.Generator project
run: |
dotnet run -c Release
working-directory: src/Cropper.Blazor/Cropper.Blazor.Sitemap.Generator
- name: Check if sitemap.xml File Exists
run: |
filePath="./sitemap.xml"
if [ -f "$filePath" ]; then
echo "sitemap.xml file exists"
else
echo "File does not exist"
exit 1
fi
working-directory: src/Cropper.Blazor/Client/wwwroot
# publishes Blazor project to the release-folder
- name: Publish .NET Core Project
run: dotnet publish ./src/Cropper.Blazor/Client/Cropper.Blazor.Client.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
needs: code-quality-check
env:
JAVA_HOME: '/home/runner/android-sdk'
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8, 7, 6
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Cache JDK
id: cache-jdk
uses: actions/cache@v4
with:
path: ${{ env.JAVA_HOME }}
key: ${{ runner.os }}-jdk-11
restore-keys: |
${{ runner.os }}-jdk-
- name: Setup Java JDK
if: steps.cache-jdk.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: 11
- name: search workloads
run: dotnet workload search
- name: Install Windows, Android MAUI Workloads
run: |
dotnet workload install maui-windows maui-android --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/8.0.1xx.json --ignore-failed-sources
dotnet workload install wasm-tools --ignore-failed-sources
- name: list workloads
run: dotnet workload list
- name: Restore dotnet workload
run: dotnet workload restore
working-directory: examples
- name: Restore dependencies for Cropper.Blazor.Demo
run: dotnet restore
working-directory: examples
- name: Restore dotnet tool
run: dotnet tool restore
working-directory: src/Cropper.Blazor/Cropper.Blazor
- 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
- name: DotNet Build Blazor Server Demo Project for .net 8
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.Server.Net8
- name: DotNet Build Blazor MAUI Demo Project for .net 8
run: dotnet build --no-restore
working-directory: examples\Cropper.Blazor.MAUI.Net8