package.sh shellcheck and add require check

Signed-off-by: wangqing <wangqing@uniontech.com>
This commit is contained in:
wangqing 2022-03-29 11:29:02 +08:00
parent 12e680d454
commit 9afe9038fd
1 changed files with 26 additions and 12 deletions

View File

@ -1,23 +1,37 @@
#!/bin/bash
green="\033[32m"
check_cmd() {
local cmd="$1"
if ! command -v "${cmd}" >/dev/null 2>&1; then
echo >&2 "I require ${cmd} but it's not installed. Aborting."
exit 1
fi
}
green() {
printf '\33[1;32m%b\n\33[0m' "$1"
}
check_cmd yarn
check_cmd tar
RELEASE=sysomRelease-$(date +"%Y%m%d%H%M%S")
APIDIR=sysom_api
WEBDIR=sysom_web
SCRIPTDIR=script
TOOLSDIR=tools
# build web
pushd sysom_web
pushd sysom_web || exit
yarn
yarn build
popd
popd || exit
mkdir -p ${RELEASE}
cp -r ${APIDIR}/ ${TOOLSDIR}/ ${RELEASE}/
cp -r ${WEBDIR}/dist/ ${RELEASE}/${WEBDIR}/
mkdir -p ${RELEASE}/${WEBDIR}/download/
cp ${TOOLSDIR}/deploy/deploy.sh ${RELEASE}/
cp -r ${SCRIPTDIR} ${RELEASE}/
tar czf ${RELEASE}.tar.gz ${RELEASE}/
rm -rf ${RELEASE}
printf "$green The release pacakge is ${RELEASE}.tar.gz\n\033[0m"
mkdir -p "${RELEASE}"
cp -r ${APIDIR}/ ${TOOLSDIR}/ "${RELEASE}"/
cp -r ${WEBDIR}/dist/ "${RELEASE}"/${WEBDIR}/
mkdir -p "${RELEASE}"/${WEBDIR}/download/
cp ${TOOLSDIR}/deploy/deploy.sh "${RELEASE}"/
cp -r ${SCRIPTDIR} "${RELEASE}"/
tar czf "${RELEASE}".tar.gz "${RELEASE}"/
rm -rf "${RELEASE}"
green "The release pacakge is ${RELEASE}.tar.gz"