feat: 支持 MOBI 版 (#21) #98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- ".github/**" | |
- ".vitepress/**" | |
- "src/**" | |
- "theme/**" | |
- "book.toml" | |
- "package-lock.json" | |
- "package.json" | |
permissions: | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build and deploy | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: current | |
- name: Install node packages | |
run: npm ci | |
- name: Install mdBook | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: mdbook | |
git: https://github.com/rust-lang/mdBook | |
- name: Install mdbook-epub | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: mdbook-epub | |
git: https://github.com/Michael-F-Bryan/mdbook-epub | |
- name: Install mdbook-typst-pdf | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: mdbook-typst-pdf | |
git: https://github.com/KaiserY/mdbook-typst-pdf | |
- name: Install fonts | |
run: | | |
mkdir -p ~/.local/share/fonts/ | |
curl -sL -o Noto_Sans.zip https://fonts.google.com/download?family=Noto%20Sans | |
unzip Noto_Sans.zip -d ~/.local/share/fonts/Noto_Sans | |
curl -sL -o Noto_Sans_SC.zip https://fonts.google.com/download?family=Noto%20Sans%20SC | |
unzip Noto_Sans_SC.zip -d ~/.local/share/fonts/Noto_Sans_SC | |
curl -sL -o Noto_Sans_Mono.zip https://fonts.google.com/download?family=Noto%20Sans%20Mono | |
unzip Noto_Sans_Mono.zip -d ~/.local/share/fonts/Noto_Sans_Mono | |
rm -fv ~/.local/share/fonts/Noto_Sans_Mono/NotoSansMono-VariableFont_wdth,wght.ttf | |
curl -sL -o Noto_Sans_KR.zip https://fonts.google.com/download?family=Noto%20Sans%20KR | |
unzip Noto_Sans_KR.zip -d ~/.local/share/fonts/Noto_Sans_KR | |
curl -sL -o Noto_Sans_Thai.zip https://fonts.google.com/download?family=Noto%20Sans%20Thai | |
unzip Noto_Sans_Thai.zip -d ~/.local/share/fonts/Noto_Sans_Thai | |
rm -fv ~/.local/share/fonts/Noto_Sans_Thai/NotoSansThai-VariableFont_wdth,wght.ttf | |
curl -sL -o Noto_Sans_Arabic.zip https://fonts.google.com/download?family=Noto%20Sans%20Arabic | |
unzip Noto_Sans_Arabic.zip -d ~/.local/share/fonts/Noto_Sans_Arabic | |
curl -sL -o Noto_Sans_Hebrew.zip https://fonts.google.com/download?family=Noto%20Sans%20Hebrew | |
unzip Noto_Sans_Hebrew.zip -d ~/.local/share/fonts/Noto_Sans_Hebrew | |
curl -sL -o Noto_Sans_Devanagari.zip https://fonts.google.com/download?family=Noto%20Sans%20Devanagari | |
unzip Noto_Sans_Devanagari.zip -d ~/.local/share/fonts/Noto_Sans_Devanagari | |
rm -fv ~/.local/share/fonts/Noto_Sans_Devanagari/NotoSansDevanagari-VariableFont_wdth,wght.ttf | |
curl -sL -o Noto_Emoji.zip https://fonts.google.com/download?family=Noto%20Emoji | |
unzip Noto_Emoji.zip -d ~/.local/share/fonts/Noto_Emoji | |
curl -sL -o times_sans_serif.zip https://dl.dafont.com/dl/?f=times_sans_serif | |
unzip times_sans_serif.zip -d ~/.local/share/fonts/times_sans_serif | |
fc-cache -rv | |
- name: Install Calibre | |
run: | | |
sudo apt install -y libegl1 libopengl0 libxcb-cursor0 | |
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin | |
- name: Build | |
run: | | |
sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md | |
npm run build | |
ebook-convert .vitepress/dist/药娘的天空.epub .vitepress/dist/药娘的天空.mobi |