summaryrefslogtreecommitdiff
path: root/scripts/make-archive.sh
blob: b99e87ab0a3dd9146179c894adede82dcf945761 (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
62
63
64
65
66
67
68
69
70
71
72
#!/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.* \
       app.json

find ./vendor -name doc -type d -exec rm -rf {} +;
find ./vendor -name notes -type d -exec rm -rf {} +;
find ./vendor -name test -type d -exec rm -rf {} +;
find ./vendor -name tests -type d -exec rm -rf {} +;
find ./vendor -name composer.json -delete
find ./vendor -name phpunit.xml -delete
find ./vendor -name .travis.yml -delete
find ./vendor -name README.* -delete
find ./vendor -name .gitignore -delete

# 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