Skip to content

Commit 84d4439

Browse files
committed
build with docker
1 parent f2de819 commit 84d4439

1 file changed

Lines changed: 51 additions & 98 deletions

File tree

.travis.yml

Lines changed: 51 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,73 @@
1+
sudo: required
2+
13
language: node_js
24

5+
services:
6+
- docker
7+
38
node_js:
49
- "stable"
510

611
before_install:
7-
- echo "add id_rsa private key"
8-
- openssl aes-256-cbc -K $encrypted_c2697660bfd7_key -iv $encrypted_c2697660bfd7_iv
9-
-in id_rsa.enc -out ~/.ssh/id_rsa -d
10-
- chmod 600 ~/.ssh/id_rsa
11-
- eval "$(ssh-agent -s)"
12-
- ssh-add ~/.ssh/id_rsa
13-
- cp ssh_config ~/.ssh/config
14-
- git config --global user.name "rhett"
15-
- git config --global user.email [email protected]
16-
# update first
17-
- sudo apt-get update -qq
18-
# Install Gitbook
19-
- npm install gitbook-cli -g
20-
- npm install svgexport -g
21-
# install calibre latest version
22-
- sudo -v && wget --no-check-certificate -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
12+
- docker pull billryan/gitbook:latest
13+
- docker pull billryan/gitbook:zh-hans
14+
- docker pull billryan/gitbook:zh-hant
15+
- alias gitbook_en='docker run --rm -v "$PWD":/gitbook -p 4000:4000 billryan/gitbook:latest gitbook'
16+
- alias gitbook_zh_hans='docker run --rm -v "$PWD":/gitbook -p 4000:4000 billryan/gitbook:zh-hans gitbook'
17+
- alias gitbook_zh_hant='docker run --rm -v "$PWD":/gitbook -p 4000:4000 billryan/gitbook:zh-hant gitbook'
18+
19+
install:
20+
# Install GitBook dependencies
21+
- echo "install gitbook dependencies..."
22+
- gitbook_en install
2323

2424
before_script:
25-
- cd ~
26-
- wget http://devtools.qiniu.io/qiniu-devtools-linux_amd64-current.tar.gz
27-
- tar xfz qiniu-*.tar.gz
28-
- git clone https://github.com/billryan/algorithm-exercise.git ~/algorithm-exercise
29-
- echo "install gitbook plugins..."
30-
- cd ~/algorithm-exercise/
31-
- cp LANGS.md LANGS_bak.md
32-
- gitbook install
33-
- cp ~/algorithm-exercise/scripts/rename_ebook.sh ~/
34-
- cp ~/algorithm-exercise/conf/qiniu_sync.json ~/
35-
- sed -i "s/AccessKey/$QAK/g" ~/qiniu_sync.json
36-
- sed -i "s/SecretKey/$QSK/g" ~/qiniu_sync.json
37-
- mkdir -p ~/upload
38-
- mkdir -p ~/raw_fonts
39-
- mkdir -p ~/.fonts/noto
40-
- mkdir -p ~/.fonts/arial
25+
- cp LANGS.md LANGS.md.bak
4126

4227
script:
43-
- echo "build English ebook..."
44-
# - wget -P ~/raw_fonts https://noto-website.storage.googleapis.com/pkgs/NotoSans-unhinted.zip
45-
# - wget -P ~/raw_fonts https://github.com/billryan/algorithm-exercise/files/277714/migu-1m-20150712.zip
46-
- wget -P ~/raw_fonts https://github.com/billryan/algorithm-exercise/files/279471/arial.zip
47-
- echo "install fonts Noto Sans CJK SC for Simplified Chinese"
48-
- wget -P ~/raw_fonts https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKsc-hinted.zip
49-
- cd ~/raw_fonts
50-
# - unzip -o NotoSans-unhinted.zip
51-
# - unzip -o migu-1m-20150712.zip
52-
- unzip -o arial.zip
53-
- mv -t ~/.fonts/arial Arial*ttf
54-
- unzip -o NotoSansCJKsc-hinted.zip
55-
# discard other fonts since fontconfig 2.11 cannot identify it
56-
- mv -t ~/.fonts/noto *-DemiLight.otf *-Bold.otf *-Black.otf
57-
- sudo fc-cache -f -v
58-
- cd ~/algorithm-exercise/
59-
- sed '/\(en\/\)/! d' LANGS_bak.md > LANGS.md
60-
#- gitbook build ./
61-
- gitbook pdf ./
62-
- gitbook epub ./
63-
- gitbook mobi ./
28+
- echo "build English ebook"
29+
- sed '/\(en\/\)/! d' LANGS.md.bak > LANGS.md
30+
- gitbook_en pdf .
31+
- gitbook_en epub .
32+
- gitbook_en mobi .
6433

6534
- echo "build Simplified Chinese ebook"
66-
- sed '/\(zh-hans\/\)/! d' LANGS_bak.md > LANGS.md
67-
- cd ~/algorithm-exercise/
68-
#- gitbook build ./
69-
- gitbook pdf ./
70-
- gitbook epub ./
71-
- gitbook mobi ./
72-
# clear CJK fonts(CJK fonts suffer in fontconfig :(
73-
- rm ~/.fonts/noto/*.otf
35+
- sed '/\(zh-hans\/\)/! d' LANGS.md.bak > LANGS.md
36+
- gitbook_zh_hans pdf .
37+
- gitbook_zh_hans epub .
38+
- gitbook_zh_hans mobi .
7439

7540
- echo "build Traditional Chinese ebook"
76-
- sed '/\(zh-tw\/\)/! d' LANGS_bak.md > LANGS.md
77-
- echo "install fonts Noto Sans CJK TC for Traditional Chinese"
78-
- wget -P ~/raw_fonts https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKtc-hinted.zip
79-
- cd ~/raw_fonts
80-
- unzip -o NotoSansCJKtc-hinted.zip
81-
- mv -t ~/.fonts/noto *-DemiLight.otf *-Bold.otf *-Black.otf
82-
- sudo fc-cache -f -v
83-
- cd ~/algorithm-exercise/
84-
#- gitbook build ./
85-
- gitbook pdf ./
86-
- gitbook epub ./
87-
- gitbook mobi ./
41+
- sed '/\(zh-tw\/\)/! d' LANGS.md.bak > LANGS.md
42+
- gitbook_zh_hant pdf .
43+
- gitbook_zh_hant epub .
44+
- gitbook_zh_hant mobi .
45+
46+
- echo "build HTML pages"
47+
- cp LANGS.md.bak LANGS.md
48+
- gitbook_en build .
49+
- ls -alh
50+
51+
before_deploy:
52+
- tar czvf blog.tar.gz _book/
53+
54+
deploy:
55+
- provider: releases
56+
api_key:
57+
secure: QU4B9CIPUdelYJKnS72SUjOY/9/w9+m536RX8Ex4PsKYMJHEIW7rkbP16ZAvMDoqiQkfPwpQSE8tFOBxMmkgGIgWY86o0xr022ak0iGICFCkjedEfNkKBENjOA8JoMlCx+QRyGcRJKuHBAy8WQU+PKykJDzJzadGNs0ud/+P75k=
58+
file:
59+
- blog.tar.gz
60+
- book_en.pdf
61+
- book_zh-hans.pdf
62+
- book_zh-hant.pdf
63+
skip_cleanup: true
64+
on:
65+
branch: master
8866

8967
after_success:
90-
- echo "rename ebook"
91-
- cd ~/algorithm-exercise
92-
- mv *.pdf *.epub *.mobi ~/upload
93-
- cd ~/upload
94-
- sh ~/rename_ebook.sh
9568
- ls -lh
96-
# upload to GitHub and Qiniu
97-
- cd ~/algorithm-exercise
98-
- git remote add github_bak [email protected]:sign4bill/algorithm-exercise.git
99-
#- git push -u github_bak HEAD:master --force
100-
- git checkout --orphan deploy
101-
- mkdir -p {epub,pdf,mobi}
102-
- cp ~/upload/*.epub epub
103-
- cp ~/upload/*.pdf pdf
104-
- cp ~/upload/*.mobi mobi
105-
- git add epub pdf mobi
106-
- git commit -m "Updated $(date)"
107-
- git push -u github_bak deploy --force
108-
- echo "upload to Qiniu CDN for China Mainland"
109-
- ~/qrsync ~/qiniu_sync.json
110-
111-
# blacklist
112-
branches:
113-
except:
114-
- deploy
11569

11670
# whitelist
11771
branches:
11872
only:
11973
- master
120-
- test

0 commit comments

Comments
 (0)