-
Notifications
You must be signed in to change notification settings - Fork 94
/
build-service-packages.sh
73 lines (47 loc) · 2.32 KB
/
build-service-packages.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
#!/usr/bin/env bash
declare BUILD_PATH=`pwd`
declare -A f2c_modules
declare -A f2c_moduleNames
function getServices() {
for _dir in $(ls -l services/ |awk '/^d/ {print $NF}')
do
f2c_moduleNames["$_dir"]=$_dir
f2c_modules["$_dir"]=$BUILD_PATH"/services/"$_dir
done
}
function build_services(){
getServices
mkdir -p ${BUILD_PATH}/target/apps/extra
touch ${BUILD_PATH}/target/apps/extra/modules
for build_module_name in "${f2c_moduleNames[@]}"
do
cd ${BUILD_PATH}/target || exit
echo ${build_module_name}
echo ${f2c_modules["$build_module_name"]}
declare APP_NAME=${build_module_name}
declare APP_PORT=`awk '/<service.port>[^<]+<\/service.port>/{gsub(/<service.port>|<\/service.port>/,"",$1);print $1;exit;}' ${f2c_modules["$build_module_name"]}/backend/pom.xml`
declare _APP_VERSION=`ls ${APP_NAME}-*.jar`
_APP_VERSION=${_APP_VERSION//.jar/}
_APP_VERSION=${_APP_VERSION//$APP_NAME-/}
echo "APP: $APP_NAME PORT: $APP_PORT APP_VERSION: $_APP_VERSION"
echo "${APP_NAME}|${APP_PORT}|${_APP_VERSION}" >> ${BUILD_PATH}/target/apps/extra/modules
cp ${BUILD_PATH}/target/${APP_NAME}-${_APP_VERSION}.jar ${BUILD_PATH}/target/apps/extra
rm -f ${BUILD_PATH}/target/apps/extra/app.yml
cp ${f2c_modules["$build_module_name"]}/${APP_NAME}.yml ${BUILD_PATH}/target/apps/extra/app.yml
cd ${BUILD_PATH}/target/apps/extra || exit
if [[ "$OSTYPE" =~ ^darwin ]]; then
sed -i "" "s/APP_VERSION/${_APP_VERSION}/" app.yml
sed -i "" "s/APP_PORT/${APP_PORT}/" app.yml
else
sed -i "s/APP_VERSION/${_APP_VERSION}/" app.yml
sed -i "s/APP_PORT/${APP_PORT}/" app.yml
fi
mv app.yml ${APP_NAME}-${_APP_VERSION}.yml
mkdir -p ${BUILD_PATH}/target/services
tar czvf ${BUILD_PATH}/target/services/${APP_NAME}-${_APP_VERSION}.tar.gz ${APP_NAME}-${_APP_VERSION}.yml ${APP_NAME}-${_APP_VERSION}.jar
md5sum -b ${BUILD_PATH}/target/services/${APP_NAME}-${_APP_VERSION}.tar.gz | awk '{print $1}' > ${BUILD_PATH}/target/services/${APP_NAME}-${_APP_VERSION}.tar.gz.md5
done
tar czvf ${BUILD_PATH}/target/services/all-services-${_APP_VERSION}.tar.gz *.yml *.jar modules
md5sum -b ${BUILD_PATH}/target/services/all-services-${_APP_VERSION}.tar.gz | awk '{print $1}' > ${BUILD_PATH}/target/services/all-services-${_APP_VERSION}.tar.gz.md5
}
build_services