forked from wieslawsoltes/XamlToCSharpGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-docs.sh
More file actions
executable file
·47 lines (37 loc) · 1.24 KB
/
build-docs.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.24 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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOCK_DIR="${SCRIPT_DIR}/site/.lunet/.build-lock"
have_rg() {
command -v rg >/dev/null 2>&1
}
search_file_regex() {
local pattern="$1"
local file_path="$2"
if have_rg; then
rg -n -e "$pattern" "$file_path"
else
grep -nE -- "$pattern" "$file_path"
fi
}
clean_docs_outputs() {
find "${SCRIPT_DIR}/src" -path '*/obj/Release/*/*.api.json' -delete
rm -rf "${SCRIPT_DIR}/site/.lunet/build/cache/api/dotnet" \
"${SCRIPT_DIR}/site/.lunet/build/www"
}
cd "${SCRIPT_DIR}"
while ! mkdir "${LOCK_DIR}" 2>/dev/null; do
sleep 1
done
trap 'rmdir "${LOCK_DIR}" 2>/dev/null || true' EXIT
dotnet tool restore
dotnet build "${SCRIPT_DIR}/XamlToCSharpGenerator.CI.slnf" -c Release --nologo -m:1 /nodeReuse:false --disable-build-servers
clean_docs_outputs
cd site
LUNET_LOG="$(mktemp)"
trap 'rm -f "${LUNET_LOG}"; rmdir "${LOCK_DIR}" 2>/dev/null || true' EXIT
dotnet tool run lunet --stacktrace build 2>&1 | tee "${LUNET_LOG}"
if search_file_regex 'ERR lunet|Error while building api dotnet|Unable to select the api dotnet output' "${LUNET_LOG}" >/dev/null; then
echo "Lunet reported API/site build errors."
exit 1
fi