forked from rubberduck203/GitNStats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·62 lines (52 loc) · 1.56 KB
/
publish.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
57
58
59
60
61
62
#!/usr/bin/env bash
set -e
usage()
{
echo "usage: publish [--skip-archive] | [-h]]"
}
archive=true
while [ "$1" != "" ]; do
case $1 in
-s | --skip-archive ) archive=false
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
framework=net5.0
project_root=src/gitnstats
project_path=${project_root}/gitnstats.csproj
bin=${project_root}/bin/Release
echo "Cleaning ${bin}"
rm -rf ${bin}/**
# build the list of runtimes by parsing the *.csproj for runtime identifiers
IFS=';' read -ra runtimes <<< "$(grep '<RuntimeIdentifiers>' ${project_path} | sed -e 's,.*<RuntimeIdentifiers>\([^<]*\)</RuntimeIdentifiers>.*,\1,g')"
for runtime in ${runtimes[@]}; do
echo "Restoring ${runtime}"
dotnet restore -r ${runtime} ${project_path}
echo "Packaging ${runtime}"
dotnet publish -c release -r ${runtime} -p:PublishSingleFile=true ${project_path}
build=${bin}/${framework}/${runtime}
publish=${build}/publish
if [[ ${runtime} != win* ]]; then
exe=${publish}/gitnstats
echo "chmod +x ${exe}"
chmod +x ${exe}
fi
if $archive; then
# subshell so we can specify the archive's root directory
(
cd ${publish}
archive=../../${runtime}.zip
echo "Compressing to ${archive}"
7z a ${archive} ./
)
else
echo "Skipping archival"
fi
done
exit 0