-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.sh
executable file
·56 lines (47 loc) · 1.89 KB
/
build.sh
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
#!/usr/bin/env bash
set -e # exit on first error
set -u # exit on using unset variable
#export LC_ALL=en_US.UTF-8
CURRENTPATH=`pwd`
VERSION=`cat src/Majorsilence.Media.Web/Majorsilence.Media.Web.csproj | grep "<Version>" | sed 's/[^0-9.]*//g'`
clean_build(){
rm -rf ./build
# Delete "bin" and "obj" folders
rm -rf `find -type d -name bin`
rm -rf `find -type d -name obj`
rm -rf `find -type d -name TestResults`
}
remove_bom_from_file_encoding()
{
# hack to remove character encoding BOM if it exists
STARTING_PATH=$1
NAME_WILDCARD=$2
# Find the first file matching the pattern
file=$(find $STARTING_PATH -name "*cobertura.xml" | head -n 1)
# Check if a file was found
if [ -n "$file" ]; then
# Remove the BOM and overwrite the original file
/usr/bin/sed -i '1s/^\xEF\xBB\xBF//' "$file"
echo "BOM removed from $file"
else
echo "No file matching the pattern was found."
fi
}
systemd_package_build()
{
mkdir -p build/linux-x64
dotnet restore src/Majorsilence.Media.Web.sln
dotnet build -c Release src/Majorsilence.Media.Web.sln
dotnet build "src/Majorsilence.Media.Web" -c Release -r linux-x64
dotnet publish "src/Majorsilence.Media.Web" -c Release -r linux-x64 --self-contained true -o build/linux-x64/media-web-linux-x64-$VERSION
#dotnet test src/Majorsilence.Media.Web.sln --collect:"XPlat Code Coverage" --logger:"nunit"
#remove_bom_from_file_encoding "./src/Majorsilence.Media.Web/TestResults" "*cobertura.xml"
dotnet build "src/Majorsilence.Media.WorkerService" -c Release -r linux-x64
dotnet publish "src/Majorsilence.Media.WorkerService" -c Release -r linux-x64 --self-contained true -o build/linux-x64/media-workerservice-linux-x64-$VERSION
cd build/linux-x64
tar -czvf media-web-linux-x64-$VERSION.tar.gz media-web-linux-x64-$VERSION
tar -czvf media-workerservice-linux-x64-$VERSION.tar.gz media-workerservice-linux-x64-$VERSION
cd $CURRENTPATH
}
clean_build
systemd_package_build