-
Notifications
You must be signed in to change notification settings - Fork 9
/
publish.sh
executable file
·96 lines (75 loc) · 2.92 KB
/
publish.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
#! /bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
if [ "$branch" == "gh-pages" ]
then
echo "You cannot run publish.sh script in gh-pages branch."
echo "Checkout master branch"
else
if [ "$branch" == "master" ]
then
pages=$(git branch | egrep gh-pages | sed -n -e 's/^ \(.*\)/\1/p')
if [ "$pages" == "gh-pages" ]
then
git branch -D gh-pages
fi
# update manifest file version
version=$(grep -Eo '# version [[:digit:]]+' plasm.js.manifest | grep -Eo [[:digit:]]+)
version=$(($version + 1))
echo "plasm.js.manifest switched to version " $version
sed 's/# version [[:digit:]]*/# version '$version'/g' plasm.js.manifest > version.manifest.temp
rm plasm.js.manifest
mv version.manifest.temp plasm.js.manifest
git commit -a -m "update plasm.js.manifest version: ready for publish"
# switch to branch gh-pages
git checkout -b gh-pages
# update index.html
sed -i".bak" '/src=\"support\/three.js\"/d' index.html
sed -i".bak" '/src=\"support\/three-detector.js\"/d' index.html
sed -i".bak" '/src=\"support\/three-frame.js\"/d' index.html
sed -i".bak" '/src=\"support\/three-stats.js\"/d' index.html
sed -i".bak" '/src=\"support\/three-trackball.js\"/d' index.html
sed -i".bak" '/src=\"node_modules\/simplexn.js\/lib\/simplexn.js\"/d' index.html
sed -i".bak" '/src=\"node_modules\/f.js\/lib\/f.js\"/d' index.html
sed -i".bak" '/src=\"lib\/plasm-fun.js\"/d' index.html
sed -i".bak" 's/ <script src="lib\/plasm.js"><\/script>/ <script src="lib\/viewer.min.js"><\/script>\
<script src="lib\/plasm.min.js"><\/script>/g' index.html
# update manifest file
sed -i".bak" '/support\/three.js/d' plasm.js.manifest
sed -i".bak" '/support\/three-detector.js/d' plasm.js.manifest
sed -i".bak" '/support\/three-frame.js/d' plasm.js.manifest
sed -i".bak" '/support\/three-stats.js/d' plasm.js.manifest
sed -i".bak" '/support\/three-trackball/d' plasm.js.manifest
sed -i".bak" '/node_modules\/simplexn.js\/lib\/simplexn.js/d' plasm.js.manifest
sed -i".bak" '/node_modules\/f.js\/lib\/f.js/d' plasm.js.manifest
sed -i".bak" '/lib\/plasm-fun.js/d' plasm.js.manifest
sed -i".bak" 's/lib\/plasm.js/lib\/viewer.min.js\
lib\/plasm.min.js/g' plasm.js.manifest
# remove unuseful files
rm index.html.bak
rm plasm.js.manifest.bak
rm History.md
rm -rf docs
rm index.js
rm package.json
rm -rf test
rm support/three-detector.js
rm support/three-frame.js
rm support/three-stats.js
rm support/three-trackball.js
rm support/three.js
rm -rf lib
rm publish.sh
rm Makefile
# move files in right place
mkdir lib
mv plasm.min.js ./lib/
mv plasm.js ./lib/
mv viewer.min.js ./lib/
# add commit and push pages
git add .
git commit -a -m "publishing gh-pages"
git push -f origin gh-pages
git checkout master
git branch -D gh-pages
fi
fi