blob: a5ca4f29b678b63d4747e26e3631ce8b5d8953f7 (
plain) (
blame)
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
|
#!/bin/bash
set -e
web_only=false
dotnet_only=false
skip_tests=false
while test $# -gt 0; do
case "$1" in
-h|--help)
echo 'options:'
echo '-h, --help show help'
echo '--web-only skip dotnet build'
echo '--dotnet-only skip web build'
echo '--skip-tests skip execution of npm and dotnet tests'
echo '--version version for the binary. defaults to current git tag+SHA'
exit 0
;;
--web-only)
web_only=true
shift
;;
--dotnet-only)
dotnet_only=true
shift
;;
--skip-tests)
skip_tests=true
shift
;;
--version)
shift
version=$1
shift
;;
*)
break
;;
esac
done
if [ -z "$version" ]; then
tag=$(git describe --tags --abbrev=0)
sha=$(git rev-parse --short HEAD)
version=$tag+$sha
fi
if [ "$dotnet_only" == true ]; then
echo $'\n\t⏩ web build skipped\n'
else
# build web
cd src/web
echo $'\n\t📍 '$(pwd)$'\n'
echo $'\n\t🛠️ npm ci\n'
npm ci
if [ "$skip_tests" == true ]; then
echo $'\n\t⏩ web tests skipped\n'
else
echo $'\n\t🧪 npm run test-unattended\n'
npm run test-unattended
fi
echo $'\n\t🛠️ npm run build\n'
npm run build
if [ "$web_only" == false ]; then
# remove old build, but keep .gitkeep
rm -rf ../slskd/wwwroot
mkdir ../slskd/wwwroot
touch ../slskd/wwwroot/.gitkeep
# copy new files
echo $'\n\t🛠️ cp -r build/* ../slskd/wwwroot/\n'
cp -r build/* ../slskd/wwwroot/
fi
cd ../..
fi
if [ "$web_only" == true ]; then
echo $'\n\t⏩ dotnet build skipped\n'
else
# build api + web
cd src/slskd
echo $'\n\t📍 '$(pwd)$'\n'
echo $'\n\t🛠️ dotnet build --no-incremental --nologo --configuration Release -p:Version '$version$'\n'
dotnet build --no-incremental --nologo --configuration Release -p:Version=$version
if [ "$skip_tests" == true ]; then
echo $'\n\t⏩ dotnet tests skipped\n'
else
echo $'\n\t🧪 dotnet test --configuration Release ../../tests/slskd.Tests.Unit\n'
dotnet test --configuration Release ../../tests/slskd.Tests.Unit
echo $'\n\t🧪 dotnet test --configuration Release ../../tests/slskd.Tests.Integration\n'
dotnet test --configuration Release ../../tests/slskd.Tests.Integration
fi
fi
echo $'\n\t🎉 build succeded!\n'
|