-
Notifications
You must be signed in to change notification settings - Fork 39
/
make.sh
executable file
·89 lines (76 loc) · 3.02 KB
/
make.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
command -v cat >/dev/null 2>&1 || { echo >&2 "[ERROR] I require cat but it's not installed. Aborting..."; exit 1; }
command -v awk >/dev/null 2>&1 || { echo >&2 "[ERROR] I require awk but it's not installed. Aborting..."; exit 1; }
command -v python >/dev/null 2>&1 || { echo >&2 "[ERROR] I require python but it's not installed. Aborting..."; exit 1; }
command -v jq >/dev/null 2>&1 || { echo >&2 "[ERROR] I require jq but it's not installed. Aborting..."; exit 1; }
IS_RELEASE=0
PAUSE_UPDATE=0
while [[ $# -gt 0 ]]
do
OPTION="$1"
case $OPTION in
-r|--release)
IS_RELEASE=1
PAUSE_UPDATE=1
;;
-p|--pause)
PAUSE_UPDATE=1
;;
*)
;;
esac
shift
done
MANIFEST="./offline-editor/manifest.json"
VERSION_KEY="version"
VERSION_NAME_KEY="version_name"
VERSION="$(cat "$MANIFEST" | jq ".$VERSION_KEY" | tr -d '"')"
NEW_VERSION_NAME="$VERSION"
VERSION_NAME="$(cat "$MANIFEST" | jq ".$VERSION_NAME_KEY" | tr -d '"')"
if [ "$IS_RELEASE" -gt 0 ]; then
echo " > Release Version Update!"
SUBVERSION=`echo $VERSION | awk -F "." '{print $2}'`
NEW_SUBVERSION=$(($SUBVERSION + 1))
NEW_VERSION=`echo $VERSION | awk -F "." '{print $1 "."'$NEW_SUBVERSION'"." 0 }'`
jq '."'$VERSION_KEY'" = "'$NEW_VERSION'"' "$MANIFEST" > .manifest.$$.json && mv .manifest.$$.json "$MANIFEST"
VERSION=$(cat "$MANIFEST" | jq ".$VERSION_KEY" | tr -d '"')
else
NEW_VERSION_NAME+="b"
fi
jq '."'$VERSION_NAME_KEY'" = "'$NEW_VERSION_NAME'"' "$MANIFEST" > .manifest.$$.json && mv .manifest.$$.json "$MANIFEST"
VERSION_NAME=$(cat "$MANIFEST" | jq ".$VERSION_NAME_KEY" | tr -d '"')
if [ "$PAUSE_UPDATE" -eq 0 ]; then
SUBVERSION=`echo $VERSION | awk -F "." '{print $3}'`
NEW_SUBVERSION=$(($SUBVERSION + 1))
NEW_VERSION=`echo $VERSION | awk -F "." '{print $1 "." $2 ".'$NEW_SUBVERSION'" }'`
jq '."'$VERSION_KEY'" = "'$NEW_VERSION'"' "$MANIFEST" > .manifest.$$.json && mv .manifest.$$.json "$MANIFEST"
VERSION=$(cat "$MANIFEST" | jq ".$VERSION_KEY" | tr -d '"')
else
echo " > Incremental Version Update Disabled!"
fi
NEW_VERSION_NAME="$VERSION"
VERSION_NAME="$(cat "$MANIFEST" | jq ".$VERSION_NAME_KEY" | tr -d '"')"
if [[ $VERSION_NAME == *b ]]; then
NEW_VERSION_NAME+="b"
echo " > Beta Release!"
else
echo " > Stable Release!"
fi
jq '."'$VERSION_NAME_KEY'" = "'$NEW_VERSION_NAME'"' "$MANIFEST" > .manifest.$$.json && mv .manifest.$$.json "$MANIFEST"
VERSION_NAME=$(cat "$MANIFEST" | jq ".$VERSION_NAME_KEY" | tr -d '"')
echo " > Building BlocklyDuino v$VERSION_NAME..."
cd blockly
cp msg/js/en.js msg/messages.js
python build.py
python joint.py
cp msg/messages.js msg/js/en.js
cd ..
cp ./blockly/apps/blocklyduino/category.xml ./offline-editor/category.xml
cp ./blockly/apps/blocklyduino/js/setCategoryCharacter.js ./offline-editor/js/setCategoryCharacter.js
cp ./blockly/*_compressed.js ./offline-editor/js/
cp ./blockly/msg/js/* ./offline-editor/msg/js/
cp ./blockly/media/* ./offline-editor/media/
cp ./blockly/apps/blocklyduino/css/* ./offline-editor/css/
python joint.py
echo ""
echo " > Done building BlocklyDuino v$VERSION_NAME! ($(/bin/date))"