Skip to content
This repository was archived by the owner on Jan 9, 2018. It is now read-only.

Commit ee81e92

Browse files
committed
Added script to create .phar from github repo
2 parents 4b46a17 + ce09dfe commit ee81e92

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

plugin.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
BRANCH="master"
4+
DEVTOOLS="DevTools.phar"
5+
CONSOLE_SCRIPT="https://raw.githubusercontent.com/PocketMine/DevTools/master/src/DevTools/ConsoleScript.php"
6+
7+
PHP="$(which php)"
8+
9+
function usage {
10+
echo "Usage: $0 [-b branch] [-d /path/to/DevTools.phar] [-p /path/to/php] <url>"
11+
exit 1
12+
}
13+
14+
while getopts "p:b:d:h" opt; do
15+
case $opt in
16+
b)
17+
BRANCH="$2"
18+
;;
19+
d)
20+
DEVTOOLS="$2"
21+
;;
22+
p)
23+
PHP="$2"
24+
;;
25+
h)
26+
usage
27+
esac
28+
done
29+
30+
shift $(expr $OPTIND - 1 )
31+
URL="$1"
32+
33+
if [ "$($PHP -r 'echo 1;' 2>/dev/null)" != "1" ]; then
34+
echo "[*] PHP not found"
35+
usage
36+
fi
37+
38+
if [ ! -f $DEVTOOLS ]; then
39+
if [ ! -f "ConsoleScript.php" ]; then
40+
echo "[*] Downloading ConsoleScript.php"
41+
wget --no-check-certificate -O - "$CONSOLE_SCRIPT" > ConsoleScript.php
42+
fi
43+
DEVTOOLS="$(pwd)/ConsoleScript.php"
44+
fi
45+
46+
if [ "$URL" == "" ]; then
47+
usage
48+
fi
49+
50+
git clone -b "$BRANCH" "$URL" plugin
51+
52+
cd plugin
53+
PLUGIN_NAME=$(grep 'name: ' plugin.yml | sed 's/^[^:]*: \(.*\)$/\1/g')
54+
PLUGIN_VERSION=$(grep 'version: ' plugin.yml | sed 's/^[^:]*: \(.*\)$/\1/g')
55+
GIT_COMMIT="$(git rev-parse HEAD)"
56+
cd ..
57+
58+
$PHP -dphar.readonly=0 "$DEVTOOLS" --make="./plugin/" --relative="./plugin/" --out "${PLUGIN_NAME}_v${PLUGIN_VERSION}-${GIT_COMMIT:0:8}.phar"
59+
rm -fr plugin

0 commit comments

Comments
 (0)