2018-10-28 22:59:15 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-04-02 15:40:09 +00:00
|
|
|
cd "$(dirname "$0")/../" || { echo "Failed to enter base directory"; exit 1; }
|
2018-10-28 22:59:15 +00:00
|
|
|
|
2019-03-17 22:23:27 +00:00
|
|
|
if [[ "$1" == "development" ]] || [[ "$1" == "dev" ]] || [[ "$1" == "dev" ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
source_path="web/environment/development"
|
|
|
|
type="development"
|
2019-02-17 15:08:10 +00:00
|
|
|
elif [[ "$1" == "release" ]] || [[ "$1" == "rel" ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
source_path="web/environment/release"
|
|
|
|
type="release"
|
|
|
|
else
|
2019-02-17 15:08:10 +00:00
|
|
|
if [[ $# -lt 1 ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
echo "Invalid argument count!"
|
|
|
|
else
|
|
|
|
echo "Invalid option $1"
|
|
|
|
fi
|
|
|
|
echo 'Available options are: "development" or "dev", "release" or "rel"'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-02-17 15:08:10 +00:00
|
|
|
if [[ ! -d "$source_path" ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
echo "Could not find environment! ($source_path)"
|
|
|
|
echo "Please generate it first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/')
|
2019-02-17 15:08:10 +00:00
|
|
|
if [[ "$response" != "" ]]; then
|
2020-04-02 20:53:48 +00:00
|
|
|
echo "You're using a private modified build! Cant assign git hash!"
|
2019-02-18 20:00:56 +00:00
|
|
|
NAME="TeaWeb-${type}.zip"
|
2018-10-28 22:59:15 +00:00
|
|
|
else
|
2019-02-18 20:00:56 +00:00
|
|
|
NAME="TeaWeb-${type}-$(git rev-parse --short HEAD).zip"
|
2018-10-28 22:59:15 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-17 15:08:10 +00:00
|
|
|
if [[ -e ${NAME} ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
echo "Found old file. Deleting it."
|
2020-04-02 15:40:09 +00:00
|
|
|
rm -r "${NAME}"
|
2018-10-28 22:59:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
current_path=$(pwd)
|
2020-04-02 15:40:09 +00:00
|
|
|
cd "$source_path" || { echo "Failed to enter source path"; exit 1; }
|
2018-10-28 22:59:15 +00:00
|
|
|
|
2020-04-02 20:53:48 +00:00
|
|
|
zip -9 -r "${NAME}" ./*; _exit_code=$?
|
|
|
|
if [[ $_exit_code -ne 0 ]]; then
|
2018-10-28 22:59:15 +00:00
|
|
|
echo "Failed to package environment!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-02 15:40:09 +00:00
|
|
|
cd "$current_path" || { echo "Failed to reenter source path"; exit 1; }
|
2018-10-28 22:59:15 +00:00
|
|
|
|
|
|
|
mv "${source_path}/${NAME}" .
|
|
|
|
echo "Release package successfully packaged!"
|
2020-04-02 20:53:48 +00:00
|
|
|
echo "Target file: ${NAME} ($(pwd))"
|