-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile.sh
More file actions
71 lines (57 loc) · 1.71 KB
/
makefile.sh
File metadata and controls
71 lines (57 loc) · 1.71 KB
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
#!/usr/env/bin sh
lastTag=$(git tag -l --sort=-version:refname "*" | head -n 1)
revision=$(git log --format=format:%H | awk '{print substr($1, 1, 7)}' | head -n 1)
version=$(echo $lastTag"-"$revision)
if [ ! -f composer.phar ]; then
echo "Download composer"
$(which php) -r "readfile('https://getcomposer.org/installer');" | php
fi
if [ ! -f box.phar ]; then
echo "Download box..."
curl -LSs https://box-project.github.io/box2/installer.php | php
fi
echo "Prepare deploy directory..."
if [ -d deploy ]; then
rm -rf deploy/*
else
mkdir deploy 2> /dev/null
fi
echo "Prepare build directory..."
if [ -d build ]; then
rm -rf build/*
else
mkdir build 2> /dev/null
fi
cp -R * build/ 2> /dev/null
echo "Changedir build"
cd build
if [ ! -z "$version " ]; then
echo "Set version $version..."
sed -ie "s/twgit_revision/$version/g" src/NMR/Application.php
fi
echo "Composer install..."
$(which php) composer.phar install -vv --no-dev
rm -f composer.phar
echo "Clean useless files..."
cd vendor && find . | grep -i "Test" | xargs rm -rf
cd ../vendor && find . | grep -E "\.md$" | xargs rm -rf
cd ../vendor && find . | grep -E "\.dist$" | xargs rm -rf
cd ../vendor && find . | grep -E "\.json$" | xargs rm -rf
cd ../vendor && find . | grep -E "LICENSE$" | xargs rm -rf
cd ../vendor && find . | grep -E "Makefile$" | xargs rm -rf
cd ../
echo "Build phar..."
$(which php) box.phar build -v
rm -f box.phar
echo "Deploy phar..."
mv *.phar ../deploy
echo "$version" >> ../deploy/REVISION.md
echo "Clean build..."
cd ..
rm -rf build
echo ""
echo "(i) To install twgit: "
if [ -f /usr/local/bin/twgit ]; then
echo "$> rm -f /usr/local/bin/twgit"
fi
echo "$> ln -sfv $(pwd)/deploy/twgit.phar /usr/local/bin/twgit"