Improve make-archive.sh

This commit is contained in:
Frédéric Guillot 2014-12-05 20:55:08 -05:00
parent 1a75d1118f
commit 2c6d810411
1 changed files with 50 additions and 19 deletions

View File

@ -1,30 +1,61 @@
#!/bin/sh
VERSION=$1
APP="kanboard"
if [ "$#" -lt 1 ]
then
echo "Usage: $0 <version> [destination]"
exit 1
fi
cd /tmp
APP="kanboard"
VERSION=$1
DESTINATION=$2
if [ -z "$2" ]
then
DESTINATION=~/Devel/websites/$APP
fi
echo "Build package for version $VERSION => $DESTINATION"
# Cleanup
rm -rf /tmp/$APP /tmp/$APP-*.zip 2>/dev/null
git clone --depth 1 https://github.com/fguillot/$APP.git
# Download source code
cd /tmp
git clone --depth 1 -q https://github.com/fguillot/$APP.git >/dev/null
rm -rf $APP/data/*.sqlite \
$APP/.git $APP/.gitignore \
$APP/scripts \
$APP/tests \
$APP/Vagrantfile \
$APP/.*.yml \
$APP/README.markdown \
$APP/docs \
$APP/Dockerfile
# Install vendors
cd /tmp/$APP
composer --prefer-dist --no-dev --optimize-autoloader --quiet install
sed -i.bak s/master/$VERSION/g $APP/app/constants.php && rm -f $APP/app/*.bak
zip -r $APP-$VERSION.zip $APP
# Remove useless files
rm -rf data/*.sqlite \
.git \
.gitignore \
scripts \
tests \
Vagrantfile \
.*.yml \
README.markdown \
docs \
Dockerfile \
composer.*
mv $APP-$VERSION.zip ~/Devel/websites/$APP
# Set the version number
sed -i.bak s/master/$VERSION/g app/constants.php && rm -f app/*.bak
cd ~/Devel/websites/$APP/
unlink $APP-latest.zip
ln -s $APP-$VERSION.zip $APP-latest.zip
# Make the archive
cd /tmp
zip -r $APP-$VERSION.zip $APP > /dev/null
mv $APP-$VERSION.zip $DESTINATION
cd $DESTINATION
# Make symlink for generic archive
if [ -L $APP-latest.zip ]
then
unlink $APP-latest.zip
ln -s $APP-$VERSION.zip $APP-latest.zip
fi
rm -rf /tmp/$APP 2>/dev/null