-
Notifications
You must be signed in to change notification settings - Fork 0
/
publisher.sh
executable file
·74 lines (63 loc) · 1.31 KB
/
publisher.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
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
DEV=
COMMIT=true
RELEASE=true
while [ -n "$1" ]; do
case $1 in
-p | --packet-only)
COMMIT=''
RELEASE=''
;;
-C | --no-commit)
COMMIT=''
;;
-R | --no-release)
RELEASE=''
;;
-d | --dev)
DEV=true
;;
esac
shift
done
cd $(dirname $0)
echo '==> Checking...'
echo
mypy . || exit $?
echo '==> Reading plugin metadata...'
echo
_PARSER=$(cat <<EOF
import json,sys
o = json.load(open(sys.argv[1],"r"))
n, d, v, m = o["name"], o["id"], o["version"], o.get("archive_name")
print((n.replace(" ", "") if n else d), v if not m else m.format(id=d, version=v), v)
EOF
)
_TG='mcdreforged.plugin.json'
data=($(python3 -c "$_PARSER" "$_TG"))
if [ $? -ne 0 ]; then
echo
echo "[ERROR] Cannot parse '${_TG}'"
exit 1
fi
name="${data[0]}"
namever="${data[1]}"
version="v${data[2]}"
if [ -n "$DEV" ]; then
output="${name}-dev"
else
output="${name}-v${namever}"
fi
echo '==> Packing source files...'
python3 -m mcdreforged pack -o ./output -n "$output" || exit $?
if ! [ -n "$DEV" ]; then
if [ -n "$COMMIT" ]; then
echo '==> Commiting git repo...'
( git add . && git commit -m "$version" && git push ) || exit $?
fi
if [ -n "$RELEASE" ]; then
echo '==> Creating github release...'
gh release create "$version" "./output/${output}.mcdr" -t "$version" -n '' || exit $?
fi
fi
echo '==> Done'