source ./common.sh

work_dir=`pwd`
dir_name=`basename $PWD`

if [ -f "custom_init.sh" ]; then
    source ./custom_init.sh
fi

reg='\.*D[1-9]$'
if [[ $dir_name =~  $reg  ]]
then
    touch bin/is_test_env
    cd ${SOURCE_DIR}
    git pull
    git checkout release
    cd $work_dir
fi

cd ${SOURCE_PATH}
echo ${COMPILE_CMD}|sh
cp ../bin/${SRC_EXE_NAME} ../../../../bin/${PROJECT_NAME}
cd $work_dir

tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'`
package_name=${dir_name}.tar.gz

tar --exclude=*.git -chzf target/${package_name} bin common.sh reload.sh restart.sh config ecosystem.config.js ${EXT_PKG_FILES}
