forked from fex-team/fis3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-doc.sh
72 lines (51 loc) · 1.67 KB
/
release-doc.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
#!/bin/bash
#set -e
## only publish doc in node 6.x
VERSION=$(node -v)
echo $VERSION
if [[ $VERSION != v6* ]]
then
exit
fi
rev="fex-team/fis3@$(git log --pretty=format:'%h' -n 1)"
echo "Fetching https://raw.githubusercontent.com/fex-team/fis3/gh-pages/commitId.log"
lastCommitId=$(curl https://raw.githubusercontent.com/fex-team/fis3/gh-pages/commitId.log)
echo "git diff --name-only $lastCommitId^..HEAD"
midified=$(git diff --name-only $lastCommitId^..HEAD)
if [ "$?" != "0" ]; then
echo "git diff --name-only HEAD^..HEAD"
midified=$(git diff --name-only HEAD^..HEAD)
fi
run="0"
# have change?
for m in $midified; do
echo $m | grep -E '^(doc/|release-doc\.sh$)'
test "$?" = "0" && run="1" && break
done
test $run = "0" && echo "#### Doc no change" && exit 0
echo "#### Document Building..."
currentCommitId=$(git rev-parse HEAD)
## 生成 API 文档
npm run jsdoc
## 编译官网
cd ./doc && npm install && node ../bin/fis.js release prod -d ./output
## 进入 output 提交编译产出到 gh-pages 分支下
cd ./output && git init && git remote add origin https://github.com/fex-team/fis3.git
## 复制测试文件
mkdir -p ./test
cp -r ../../test/attachment ./test/attachment
echo "$currentCommitId" > ./commitId.log
git config --global user.email "[email protected]"
git config --global user.name "xiangshouding"
git config credential.helper "store --file=.git/credential"
echo "https://${GH_TOKEN}:@github.com" > .git/credential
git push origin :gh-pages
git add *
git commit -am "build from ${rev}"
git branch gh-pages
git checkout gh-pages
git push -f origin gh-pages
cd ../../
sh pub.sh
# 删掉产出的 output 目录,为了方便本地跑脚本
rm -rf ./doc/output