-
Notifications
You must be signed in to change notification settings - Fork 3
/
makeRelease.sh
executable file
·119 lines (97 loc) · 2.87 KB
/
makeRelease.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Intended to be used from the project root directory
# or ./res directory
OLD_DIR=`pwd`
PROJ_DIR="."
DEST_DIR="bin"
LIB_DIR="lib"
SRC_DIR="src/main"
WP_DIR="wpPlugin"
WP_IMG_DIR="bin/pgnviewer/img"
TEST_DIR="examples"
IMG_DIR="img"
# functions
genPackedFormat() {
# pack the source with packer
cd $LIB_DIR
if [ "`which php`" = "" ];then
echo "PHP not found. Not using the PHP packer!";
else
php packerConf.php
fi
cd $OLD_DIR
cp $DEST_DIR/jsPgnViewer.js $JS_DEST_DIR/jsPgnViewerUnpacked.js
cp $DEST_DIR/jsPgnViewer.js $WP_DEST_DIR/jsPgnViewerUnpacked.js
java -cp $LIB_DIR/jsmin JSMin $DEST_DIR/jsPgnViewer.js > $JS_DEST_DIR/jsPgnViewer.js
java -cp $LIB_DIR/jsmin JSMin $DEST_DIR/jsPgnViewer.js > $WP_DEST_DIR/jsPgnViewer.js
}
makeRelease() {
if [ ! -d $SRC_DIR ];then
DEST_DIR="../bin"
SRC_DIR="../src"
TEST_DIR="../tests"
IMG_DIR="../img"
WP_DIR="../wpPlugin"
LIB_DIR="../lib"
PROJ_DIR="../"
WP_IMG_DIR="../"$WP_IMG_DIR
fi
WP_DEST_DIR=$DEST_DIR/"pgnviewer"
JS_DEST_DIR=$DEST_DIR/"jspgnviewer"
if [ ! -d $DEST_DIR ];then
mkdir $DEST_DIR
fi
if [ ! -d $JS_DEST_DIR ];then
mkdir $JS_DEST_DIR
fi
if [ ! -d $WP_DEST_DIR ];then
mkdir $WP_DEST_DIR
fi
if [ ! -d $WP_IMG_DIR ];then
mkdir -p $WP_IMG_DIR
fi
JS_VERSION=`cat jsVersion`
echo "/** Version: $JS_VERSION **/" > $JS_DEST_DIR/jsPgnViewer.js
cat $SRC_DIR/chess-game.js >> $JS_DEST_DIR/jsPgnViewer.js
cat $SRC_DIR/converter.js >> $JS_DEST_DIR/jsPgnViewer.js
cat $SRC_DIR/pgn.js >> $JS_DEST_DIR/jsPgnViewer.js
cat $SRC_DIR/yahoo-format.js >> $JS_DEST_DIR/jsPgnViewer.js
cat $SRC_DIR/board.js >> $JS_DEST_DIR/jsPgnViewer.js
cp $JS_DEST_DIR/jsPgnViewer.js $DEST_DIR
cp $TEST_DIR/samplePage.html $JS_DEST_DIR/
cp $SRC_DIR/README.txt $JS_DEST_DIR/
cp License.txt $JS_DEST_DIR/
cp -r $IMG_DIR $JS_DEST_DIR
# WP Plugin release
cp $WP_DIR/pgnviewer.php $WP_DEST_DIR/pgnviewer.php
WP_VERSION=`cat wpVersion`
cp $WP_DIR/* $WP_DEST_DIR
cp -r $IMG_DIR/* $WP_IMG_DIR
cp $JS_DEST_DIR/jsPgnViewer.js $WP_DEST_DIR
chmod -R 775 $DEST_DIR
perl -pi -e "s/WP_VERSION/$WP_VERSION/" $WP_DEST_DIR/pgnviewer.php
# WPR release
cd $DEST_DIR
NAME="pgnviewer-"`cat ../wpVersion`".tar.gz"
tar --exclude=.svn -cvzf $NAME pgnviewer
cd $OLD_DIR
# JSR release
cd $DEST_DIR
NAME="jspgnviewer-"`cat ../jsVersion`".tar.gz"
tar --exclude=.svn -cvzf $NAME jspgnviewer
cd $OLD_DIR
}
if [ $# -ge 1 ];then
if [ $1 == 'clean' ];then
echo "cleaning "$DEST_DIR
rm -rf $DEST_DIR
else
makeRelease
genPackedFormat
fi
else
echo "Usage:"
echo " We have the following targets:"
echo " release - makes a release"
echo " clean - clean the project"
fi