summaryrefslogtreecommitdiff
path: root/scripts/make-archive.sh
blob: 14f21c2b00ce0311a1ebe201ea481595e350de7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

if [ "$#" -lt 1 ]
then
    echo "Usage: $0 <version> [destination]"
    exit 1
fi

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

# Download source code
cd /tmp
git clone --depth 1 -q https://github.com/fguillot/$APP.git >/dev/null

# Install vendors
cd /tmp/$APP
composer --prefer-dist --no-dev --optimize-autoloader --quiet install

# Remove useless files
rm -rf data/*.sqlite \
       .git \
       .gitignore \
       scripts \
       tests \
       Vagrantfile \
       .*.yml \
       README.markdown \
       docs \
       Dockerfile \
       composer.*

# Set the version number
sed -i.bak s/master/$VERSION/g app/constants.php && rm -f app/*.bak

# 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