Skip to content

Commit 3c2d1ce

Browse files
committed
independent 3.21.02.doc branch、adjust travis.yml deploy.sh
1 parent 6c6db04 commit 3c2d1ce

File tree

4 files changed

+149
-38
lines changed

4 files changed

+149
-38
lines changed

.travis.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dist: trusty
22
env:
3-
global:
4-
- GH_REF: github.com/actiontech/dble-docs-cn
5-
- GH_USER: actiontech-bot
6-
- GH_MAIL: github@actionsky.com
3+
global:
4+
- GH_REF: github.com/actiontech/dble-docs-cn
5+
- GH_USER: actiontech-bot
6+
- GH_MAIL: github@actionsky.com
77

88
# 指定环境语言
99
language: node_js
@@ -27,38 +27,39 @@ notifications:
2727
# 构建的分支
2828
branches:
2929
only:
30-
- master
31-
30+
- master
31+
- develop
32+
- /^[0-9]{1}.[0-9]{2}.[0-9]{2}.doc$/ #eg: 2.20.04.doc
3233
# 调整时区
3334
before_install:
3435
- export TZ='Asia/Shanghai'
3536
- sudo apt-get install -y calibre fonts-arphic-gbsn00lp
36-
37+
3738
# 安装环境
3839
install:
39-
- npm install -g gitbook-cli
40+
- npm install -g gitbook-cli
4041
- npm install gitbook-plugin-yahei
4142
- gitbook install
42-
4343
# gitbook生成静态文件
4444
script:
4545
- gitbook build
46-
- cd ./_book
47-
- git init
48-
- git config user.name "${GH_USER}"
49-
- git config user.email "${GH_MAIL}"
50-
- git add .
51-
- git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
52-
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages
53-
- cd ..
54-
# pdf
55-
- xvfb-run gitbook pdf ./ ./dble-manual.pdf
56-
- mkdir pdf
57-
- cp dble-manual.pdf ./pdf/
58-
- cd ./pdf
59-
- git init
60-
- git config user.name "${GH_USER}"
61-
- git config user.email "${GH_MAIL}"
62-
- git add .
63-
- git commit -m "Update GitBook By TravisCI With Build PDF $TRAVIS_BUILD_NUMBER"
64-
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:pdf
46+
deploy:
47+
# deploy develop to the staging environment
48+
- provider: script
49+
skip_cleanup: true
50+
script: bash ./deploy.sh develop 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
51+
on:
52+
branch: develop
53+
# deploy master to production
54+
- provider: script
55+
skip_cleanup: true
56+
script: bash ./deploy.sh master 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
57+
on:
58+
branch: master
59+
#branch eg: 2.20.04.doc
60+
- provider: script
61+
skip_cleanup: true
62+
script: bash ./deploy.sh $TRAVIS_BRANCH 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
63+
on:
64+
all_branches: true
65+
condition: $TRAVIS_BRANCH =~ ^[0-9]{1}.[0-9]{2}.[0-9]{2}.doc$

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
## 注意
26-
本分支上的手册适用于3.21.02.0版dble,其他版本的文档请参考对应tag分支或者release版文档。
26+
本分支上的手册适用于3.21.02.x版dble,其他版本的文档请参考对应tag分支或者release版文档。
2727

2828
## 提示
2929
[如果您使用了dble,请告诉我们。](https://wj.qq.com/s/2291106/09f4)

book.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
{
2-
"plugins": ["expandable-chapters", "splitter", "back-to-top-button","github","popup"],
2+
"plugins": ["expandable-chapters", "splitter", "back-to-top-button","github","popup","versions-select"],
33
"pluginsConfig": {
44
"fontsettings": {
55
"theme": "sepia",
66
"family": "sans",
77
"size": 2
88
},
9-
"github":{
10-
"url":"https://github.com/actiontech/dble"
11-
},
12-
"plugins": [
13-
"yahei",
14-
"katex",
15-
"-search"
16-
]
9+
"versions": {
10+
"gitbookConfigURL": "https://raw.githubusercontent.com/actiontech/dble-docs-cn/master/book.json"
11+
},
12+
"github":{
13+
"url":"https://github.com/actiontech/dble"
14+
},
15+
"plugins": [
16+
"yahei",
17+
"katex",
18+
"-search"
19+
]
1720
},
1821
"styles": {
1922
"website": "website.css",

deploy.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION="$1"
5+
DEPLOY="$2"
6+
GH_TOKEN="$3"
7+
TRAVIS_BUILD_NUMBER="$4"
8+
9+
10+
GH_REF="github.com/actiontech/dble-docs-cn"
11+
GH_USER="actiontech-bot"
12+
GH_MAIL="github@actionsky.com"
13+
14+
reg='^[0-9]{1}\.[0-9]{2}\.[0-9]{2}\.doc$' #eg: 2.20.04.doc
15+
if [ "$VERSION" = "master" ]; then
16+
# pdf
17+
# xvfb-run gitbook pdf ./ ./dble-manual.pdf
18+
mkdir -p _book/history/develop
19+
# merge history—pages
20+
mkdir _old_book
21+
cd ./_old_book
22+
COMMAND_LINE="git clone -b history-pages https://${GH_REF}.git"
23+
eval "$COMMAND_LINE"
24+
cd dble-docs-cn
25+
git archive history-pages | tar -x -C ../../_book/history/
26+
cd ../..
27+
# merge develop—pages
28+
mkdir _develop_book
29+
cd ./_develop_book
30+
COMMAND_LINE="git clone -b develop-pages https://${GH_REF}.git"
31+
eval "$COMMAND_LINE"
32+
cd dble-docs-cn
33+
git archive develop-pages | tar -x -C ../../_book/history/develop/
34+
#deploy
35+
if [ "$DEPLOY" = "1" ]; then
36+
cd ../../_book
37+
git init
38+
git config user.name "${GH_USER}"
39+
git config user.email "${GH_MAIL}"
40+
git add .
41+
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
42+
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" master:gh-pages
43+
fi
44+
45+
elif [ "$VERSION" = "develop" ]; then
46+
# merge master—pages
47+
mkdir _master_book
48+
cd ./_master_book
49+
COMMAND_LINE="git clone -b gh-pages https://${GH_REF}.git"
50+
eval "$COMMAND_LINE"
51+
rm -rf dble-docs-cn/history/develop/
52+
cd ..
53+
cp -R _book/ _master_book/dble-docs-cn/history/develop/
54+
#deploy to develop—pages
55+
if [ "$DEPLOY" = "1" ]; then
56+
# push gh-pages
57+
cd ./_master_book/dble-docs-cn
58+
git add .
59+
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
60+
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" gh-pages:gh-pages
61+
# push develop—pages
62+
cd ../../_book
63+
git init
64+
git config user.name "${GH_USER}"
65+
git config user.email "${GH_MAIL}"
66+
git add .
67+
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
68+
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" master:develop-pages
69+
fi
70+
elif [[ "$VERSION" =~ $reg ]]; then
71+
mkdir _old_book
72+
cd ./_old_book
73+
COMMAND_LINE="git clone -b history-pages https://${GH_REF}.git"
74+
eval "$COMMAND_LINE"
75+
rm -rf dble-docs-cn/$VERSION
76+
cd ..
77+
cp -R _book/ _old_book/dble-docs-cn/$VERSION
78+
cd _old_book/dble-docs-cn/$VERSION
79+
rm -rf .gitignore .travis.yml deploy.sh package-lock.json
80+
81+
cd ../../..
82+
mkdir _master_book
83+
cd ./_master_book
84+
COMMAND_LINE="git clone -b gh-pages https://${GH_REF}.git"
85+
eval "$COMMAND_LINE"
86+
rm -rf dble-docs-cn/history/$VERSION/
87+
cd ..
88+
cp -R _book/ _master_book/dble-docs-cn/history/$VERSION/
89+
cd _master_book/dble-docs-cn/history/$VERSION/
90+
rm -rf .gitignore .travis.yml deploy.sh package-lock.json
91+
cd ../../../..
92+
93+
## push
94+
if [ "$DEPLOY" = "1" ]; then
95+
cd ./_old_book/dble-docs-cn ##history-pages
96+
git add .
97+
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
98+
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" history-pages:history-pages
99+
cd ../../
100+
cd ./_master_book/dble-docs-cn ##gh-pages
101+
git add .
102+
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
103+
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" gh-pages:gh-pages
104+
fi
105+
else
106+
echo "do nothing"
107+
fi

0 commit comments

Comments
 (0)