-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
93 lines (71 loc) · 2.11 KB
/
update.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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NC='\033[0m'
echo "\n${YELLOW}Build distribution and documentation files, committing them and updating website branch.${NC}\n"
git status
# Ensure we have committed changes.
echo "\n${YELLOW}Have you committed your changes in master?${NC}"
read -p 'yes/no: ' answer
if [ "$answer" != "yes" ]
then
echo "\n${RED}You need to commit your changes before procceding.${NC}\n"
exit
fi
# Needs to be in git master branch.
$isInMaster=`git branch | grep "* master" | wc -l`
if [ "$isInMaster" = 0 ]
then
echo "\n${RED}You need to be in master branch before procceding.${NC}\n"
exit
fi
echo "\n${BLUE}>>> Building and committing source code...${NC}\n"
./node_modules/.bin/gulp build
git add --all dist
git commit -m "build: distribution"
echo "\n${BLUE}>>> Creating and committing documentation...${NC}\n"
./node_modules/.bin/gulp docs
git add --all doc
git commit -m "docs: api"
echo "\n${BLUE}>>> Copying files...${NC}\n"
cp -r lib lib.temp
cp -r dist dist.temp
cp -r site site.temp
cp -r demo demo.temp
cp -r doc doc.temp
cp -r index.html index.html.temp
cp -r README.md README.md.temp
cp -r LICENSE LICENSE.temp
cp -r .gitignore .gitignore.temp
echo "\n${BLUE}>>> Changing to gh-pages branch...${NC}\n"
git checkout gh-pages
echo "\n${BLUE}>>> Removing current site files...${NC}\n"
rm -rf lib
rm -rf dist
rm -rf site
rm -rf demo
rm -rf doc
rm -rf index.html
rm -rf README.md
rm -rf LICENSE
rm -rf .gitignore
echo "\n${BLUE}>>> Installing updated files...${NC}\n"
mv -T -f lib.temp lib
mv -T -f dist.temp dist
mv -T -f site.temp site
mv -T -f demo.temp demo
mv -T -f doc.temp doc
mv -T -f index.html.temp index.html
mv -T -f README.md.temp README.md
mv -T -f LICENSE.temp LICENSE
mv -T -f .gitignore.temp .gitignore
echo "\n${BLUE}>>> Committing changes...${NC}\n"
git add --all lib dist site demo doc index.html README.md LICENSE .gitignore
git commit -m "chore: update site"
git push origin gh-pages
echo "\n${BLUE}>>> Changing to master branch...${NC}\n"
git checkout master
echo "\n${GREEN}>>> Repository and site are now updated.${NC}\n"
exit