Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (59 sloc) 1.91 KB
#!/bin/bash
set -e
MY_PATH=$(cd ${0%/*} && echo $PWD/${0##*/})
TOOL_PATH=`dirname "$MY_PATH"`
PFC_PATH=$TOOL_PATH/..
VERSION=`$TOOL_PATH/get-version`
# if version do not exists as a tag,
# get the latest commit id as the latest version number
if [ "`git tag -l | grep $VERSION`" == "" ]; then
VERSION_GIT="`git log --pretty=format:'%h' -n 1`"
else
VERSION_GIT="$VERSION"
fi
# a temp folder to clone the git
TMP_DIR=$PFC_PATH/tmp
mkdir -p $TMP_DIR
if [ "$1" == "--dev" ]; then
PFC_AN_SUFFIX="-dev"
PFC_ARCHIVE_NAME="phpfreechat-`$TOOL_PATH/get-version`"
# clone the git with the correct name
rm -rf $TMP_DIR/$PFC_ARCHIVE_NAME
git clone file://$PFC_PATH $TMP_DIR/$PFC_ARCHIVE_NAME
# cleanup the pfc files
cd $TMP_DIR/$PFC_ARCHIVE_NAME
git checkout $VERSION_GIT
make clean-release-for-dev
elif [ "$1" == "--debug" ]; then
PFC_AN_SUFFIX="-debug"
PFC_ARCHIVE_NAME="phpfreechat-`$TOOL_PATH/get-version`"
# clone the git with the correct name
rm -rf $TMP_DIR/$PFC_ARCHIVE_NAME
git clone file://$PFC_PATH $TMP_DIR/$PFC_ARCHIVE_NAME
# cleanup the pfc files
cd $TMP_DIR/$PFC_ARCHIVE_NAME
git checkout $VERSION_GIT
make clean-release-for-debug
else
PFC_AN_SUFFIX=""
PFC_ARCHIVE_NAME="phpfreechat-`$TOOL_PATH/get-version`"
# clone the git with the correct name
rm -rf $TMP_DIR/$PFC_ARCHIVE_NAME
git clone file://$PFC_PATH $TMP_DIR/$PFC_ARCHIVE_NAME
# cleanup the pfc files
cd $TMP_DIR/$PFC_ARCHIVE_NAME
git checkout $VERSION_GIT
make clean-release-for-prod
fi
# generate the tar.gz and .zip
cd $TMP_DIR
tar czf $PFC_ARCHIVE_NAME$PFC_AN_SUFFIX.tar.gz $PFC_ARCHIVE_NAME/
zip -Tq9r $PFC_ARCHIVE_NAME$PFC_AN_SUFFIX.zip $PFC_ARCHIVE_NAME/
# move archives into a version directory ready to upload
mkdir -p $PFC_PATH/$VERSION
mv $PFC_ARCHIVE_NAME$PFC_AN_SUFFIX.tar.gz $PFC_PATH/$VERSION/
mv $PFC_ARCHIVE_NAME$PFC_AN_SUFFIX.zip $PFC_PATH/$VERSION/
# cleanup
rm -rf $TMP_DIR
cd $PFC_PATH
exit 0