forked from billryan/algorithm-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
120 lines (111 loc) · 3.96 KB
/
.travis.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
language: node_js
node_js:
- "stable"
before_install:
- echo "add id_rsa private key"
- openssl aes-256-cbc -K $encrypted_c2697660bfd7_key -iv $encrypted_c2697660bfd7_iv
-in id_rsa.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- cp ssh_config ~/.ssh/config
- git config --global user.name "rhett"
- git config --global user.email [email protected]
# update first
- sudo apt-get update -qq
# Install Gitbook
- npm install gitbook-cli -g
- npm install svgexport -g
# install calibre latest version
- 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()"
before_script:
- cd ~
- wget http://devtools.qiniu.io/qiniu-devtools-linux_amd64-current.tar.gz
- tar xfz qiniu-*.tar.gz
- git clone https://github.com/billryan/algorithm-exercise.git ~/algorithm-exercise
- echo "install gitbook plugins..."
- cd ~/algorithm-exercise/
- cp LANGS.md LANGS_bak.md
- gitbook install
- cp ~/algorithm-exercise/scripts/rename_ebook.sh ~/
- cp ~/algorithm-exercise/conf/qiniu_sync.json ~/
- sed -i "s/AccessKey/$QAK/g" ~/qiniu_sync.json
- sed -i "s/SecretKey/$QSK/g" ~/qiniu_sync.json
- mkdir -p ~/upload
- mkdir -p ~/raw_fonts
- mkdir -p ~/.fonts/noto
- mkdir -p ~/.fonts/arial
script:
- echo "build English ebook..."
# - wget -P ~/raw_fonts https://noto-website.storage.googleapis.com/pkgs/NotoSans-unhinted.zip
# - wget -P ~/raw_fonts https://github.com/billryan/algorithm-exercise/files/277714/migu-1m-20150712.zip
- wget -P ~/raw_fonts https://github.com/billryan/algorithm-exercise/files/279471/arial.zip
- echo "install fonts Noto Sans CJK SC for Simplified Chinese"
- wget -P ~/raw_fonts https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKsc-hinted.zip
- cd ~/raw_fonts
# - unzip -o NotoSans-unhinted.zip
# - unzip -o migu-1m-20150712.zip
- unzip -o arial.zip
- mv -t ~/.fonts/arial Arial*ttf
- unzip -o NotoSansCJKsc-hinted.zip
# discard other fonts since fontconfig 2.11 cannot identify it
- mv -t ~/.fonts/noto *-DemiLight.otf *-Bold.otf *-Black.otf
- sudo fc-cache -f -v
- cd ~/algorithm-exercise/
- sed '/\(en\/\)/! d' LANGS_bak.md > LANGS.md
#- gitbook build ./
- gitbook pdf ./
- gitbook epub ./
- gitbook mobi ./
- echo "build Simplified Chinese ebook"
- sed '/\(zh-hans\/\)/! d' LANGS_bak.md > LANGS.md
- cd ~/algorithm-exercise/
#- gitbook build ./
- gitbook pdf ./
- gitbook epub ./
- gitbook mobi ./
# clear CJK fonts(CJK fonts suffer in fontconfig :(
- rm ~/.fonts/noto/*.otf
- echo "build Traditional Chinese ebook"
- sed '/\(zh-tw\/\)/! d' LANGS_bak.md > LANGS.md
- echo "install fonts Noto Sans CJK TC for Traditional Chinese"
- wget -P ~/raw_fonts https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKtc-hinted.zip
- cd ~/raw_fonts
- unzip -o NotoSansCJKtc-hinted.zip
- mv -t ~/.fonts/noto *-DemiLight.otf *-Bold.otf *-Black.otf
- sudo fc-cache -f -v
- cd ~/algorithm-exercise/
#- gitbook build ./
- gitbook pdf ./
- gitbook epub ./
- gitbook mobi ./
after_success:
- echo "rename ebook"
- cd ~/algorithm-exercise
- mv *.pdf *.epub *.mobi ~/upload
- cd ~/upload
- sh ~/rename_ebook.sh
- ls -lh
# upload to GitHub and Qiniu
- cd ~/algorithm-exercise
- git remote add github_bak [email protected]:sign4bill/algorithm-exercise.git
#- git push -u github_bak HEAD:master --force
- git checkout --orphan deploy
- mkdir -p {epub,pdf,mobi}
- cp ~/upload/*.epub epub
- cp ~/upload/*.pdf pdf
- cp ~/upload/*.mobi mobi
- git add epub pdf mobi
- git commit -m "Updated $(date)"
- git push -u github_bak deploy --force
- echo "upload to Qiniu CDN for China Mainland"
- ~/qrsync ~/qiniu_sync.json
# blacklist
branches:
except:
- deploy
# whitelist
branches:
only:
- master
- test