-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·109 lines (100 loc) · 3.09 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
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
#!/bin/bash
if [[ ${debug:-false} == true ]]; then
set -o xtrace # activate bash debug
mvnDebug="-X"
fi
build_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ts=$(date +"%Y%m%d-%H%M%S")
build_local=1
local_cache=
for i in "$@"; do
case $i in
--diag)
build_local=0
diag=1
;;
--deploy)
build_local=0
build_deploy=1
;;
# optional configurable features
--jar-signing)
jar_signing=-Dperform-jar-signing=true
;;
--gpg-signing)
gpg_signing=-Dperform-gpg-signing=true
;;
--local-cache)
read -p "delete local cache? (y/n) " -n 1 -r; echo; [[ $REPLY =~ ^[Yy]$ ]] && rm -rf ${build_dir}/.local_m2_cache
local_cache=-Dmaven.repo.local=.local_m2_cache
;;
# break for unknown options
-*|--*)
echo "unknow option $i provided"
exit 1
;;
*)
;;
esac
done
mkdir _log >/dev/null 2>&1
log_file=_log/${ts}_build.log
echo -e "#\n# build - log file $log_file\n#\n" 2>&1 | tee -a $log_file
echo -e "#\n# sourcing environment from build\n#\n" 2>&1 | tee -a $log_file
. ~/.klibio/klibio.sh
. ~/.klibio/set-java.sh 17 # must not use pipe `2>&1 | tee -a $log_file`, cause export env vars will not work
# signing
echo -e "#\n# sourcing sign properties\n#\n" 2>&1 | tee -a $log_file
readPropertyFile certificate/sign.properties # must not use pipe `2>&1 | tee -a $log_file`, cause export env vars will not work
env | grep "sign_" 2>&1 | tee -a $log_file
if [[ $sign_skip -eq "true" ]]; then
keystore=-Dkeystore=${build_dir}/certificate/${sign_keystore}
read -r -d '' signVM << EOM
-Dsign_skip=$sign_skip \
-Dsign_alias=$sign_alias \
-Dsign_keypass=$sign_keypass \
-Dsign_keystore=$sign_keystore \
-Dsign_storepass=$sign_storepass
EOM
fi
echo -e "# end of signing properties\n"2>&1 | tee -a $log_file
if [[ ${diag} -eq 1 ]]; then
echo -e "#\n# execute diagnose\n#\n" 2>&1 | tee -a $log_file
./mvnw \
${MAVEN_OPTS} \
${mvnDebug} \
${gpg_signing}
${local_cache} \
help:effective-settings 2>&1 | tee -a $log_file
fi
if [[ ${build_local} -eq 1 ]]; then
echo -e "#\n# execute local build - log file $log_file\n#\n" 2>&1 | tee -a $log_file
read -r -d '' command << EOM
./mvnw clean verify \
${MAVEN_OPTS} \
${mvnDebug} \
${local_cache} \
${gpg_signing} \
${keystore} \
${signVM}
EOM
echo -e "#\n$command\n#\n" 2>&1 | tee -a $log_file
set -e
$command 2>&1 | tee -a $log_file
fi
if [[ ${build_deploy} -eq 1 ]]; then
echo -e "#\n#\n# execute SNAPSHOT/RELEASE build - log file $log_file\n#\n#\n" 2>&1 | tee -a $log_file
read -r -d '' command << EOM
./mvnw clean deploy -Ddeploy-maven-to-klibio=true \
${MAVEN_OPTS} \
${mvnDebug} \
${local_cache} \
${gpg_signing} \
${keystore} \
${signVM}
EOM
echo -e "#\n$command\n#\n" 2>&1 | tee -a $log_file
set -e
$command 2>&1 | tee -a $log_file
fi
echo -e "#\n# execute build $build_rev completed - log file created $log_file\n#\n" 2>&1 | tee -a $log_file