forked from Automattic/jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-jetpack.sh
More file actions
executable file
·76 lines (61 loc) · 1.87 KB
/
build-jetpack.sh
File metadata and controls
executable file
·76 lines (61 loc) · 1.87 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
72
73
74
75
76
#!/bin/bash
RED='\033[0;31m'
trap 'exit_build' ERR
function exit_build {
echo -e "${RED}Something went wrong and the build has stopped. See error above for more details."
exit 1
}
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
CLEANUP=0
ADD_BETA_VERSION=0
while getopts "db" opt; do
case "$opt" in
d) CLEANUP=1
;;
b) ADD_BETA_VERSION=1
;;
esac
done
shift $((OPTIND-1))
GET_VERSION_SCRIPT="`pwd`/tools/get-version.sh"
TARGET_BRANCH=${1:-master}
TARGET_REPO=${2:-"Automattic/jetpack"}
TARGET_DIR=${3:-"/tmp/jetpack"}
[ "$1" = "--" ] && shift
if [[ $CLEANUP -eq 1 ]]; then
echo "Cleaning up existing paths.."
rm -rf $TARGET_DIR
echo "Done!"
fi
git clone \
--branch $TARGET_BRANCH \
--depth 1000 \
git://github.com/$TARGET_REPO.git \
$TARGET_DIR
cd $TARGET_DIR
if [[ $ADD_BETA_VERSION -eq 1 ]]; then
echo "Changing version of the Jetpack to reflect the latest changes.."
CURRENT_VERSION="`$GET_VERSION_SCRIPT`"
sed -i -e 's/Version: .*$/Version: '$CURRENT_VERSION'/' jetpack.php
echo $CURRENT_VERSION > version.txt
echo "Now at version $CURRENT_VERSION!"
fi
# Checking for yarn
hash yarn 2>/dev/null || {
echo >&2 "This script requires you to have yarn package manager installed."
echo >&2 "Please install it following the instructions on https://yarnpkg.com. Aborting.";
exit 1;
}
yarn --modules-folder=$TARGET_DIR/node_modules
NODE_ENV=production BABEL_ENV=production $TARGET_DIR/node_modules/.bin/gulp
echo "Purging paths included in .svnignore, .gitignore and .git itself"
# check .svnignore
for file in $( cat "$TARGET_DIR/.svnignore" 2>/dev/null ); do
if [[ $file == "to-test.md" || $file == "docs/testing/testing-tips.md" ]]; then
continue
fi
rm -rf $TARGET_DIR/$file
done
echo "Done!"