-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·63 lines (48 loc) · 1.66 KB
/
build.sh
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
#!/bin/bash
BOXBIN=`dirname $0`/box.php
BINDIR=bin/
oldversion=`${BINDIR}/yamltools --version --raw`
printf "Current version: \033[01m%s\033[00m\n" ${oldversion}
# Version number is required to run a build
if [ -z "$1" ]
then
printf "Version number is required. Exiting\n"
exit 1
fi
version=$1
shift 1
# The new build version must be different from the current one
if [ "${oldversion}" = "${version}" ]
then
printf "Cannot use the same version number for 2 different builds. Exiting\n"
exit 1
fi
printf "Building version: \033[01m%s\033[00m\n" ${version}
# Make sure vendor dir is up to date with composer-lock, and remove
# dev dependencies to be sure they won't be included in the PHAR
rm -rf vendor/*
offenbach install --no-dev
offenbach dump-autoload --optimize
# Create temporary distributable application file
cp ${BINDIR}/application.php ${BINDIR}/app.php
sed -i "s/@@version@@/${version}/" ${BINDIR}/app.php
sed -i "s/E_ALL/E_ERROR/" ${BINDIR}/app.php
# Launch box build command
php -d phar.readonly=0 $BOXBIN ${version}
#phpcc -d src -d vendor -e bin/app.php -o bin/yamltools.phar
# Remove temporary distributable application file
rm ${BINDIR}/app.php
# Post-build processing:
# - remove phar extension from binary name
# - generate MD5 & SHA384 signature files
cd $BINDIR
mv -v yamltools.phar yamltools
php -r "echo hash('md5', file_get_contents('yamltools'));" > yamltools.md5
php -r "echo hash('sha384', file_get_contents('yamltools'));" > yamltools.sha384
cd -
# Restore dev dependencies into the project
offenbach install
# Restore the genuine composer files
git checkout -- composer.json composer.lock
# Run smoke test
${BINDIR}/yamltools --version