Skip to content

Commit 845ab04

Browse files
Add epub and pdf generation via mdbook-pandoc workflow
1 parent a2d7d49 commit 845ab04

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/epub.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: epub
2+
3+
on:
4+
push:
5+
branches:
6+
- epub
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Build EPUB and PDF
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Tectonic
20+
uses: wtfjoke/setup-tectonic@v1
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Install Pandoc and Fonts
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y pandoc fonts-noto-cjk
28+
29+
- name: Install mdbook
30+
uses: peaceiris/actions-mdbook@v1
31+
with:
32+
mdbook-version: "latest"
33+
34+
- name: Install mdbook-pandoc
35+
run: |
36+
cargo install mdbook-pandoc
37+
38+
- name: Build Book
39+
run: mdbook build
40+
41+
- name: List Output Directory
42+
if: always()
43+
run: find book -maxdepth 4
44+
45+
- name: Upload EPUB
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: rust-course-epub
49+
path: book/pandoc/epub/rust-course.epub
50+
51+
- name: Upload PDF
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: rust-course-pdf
55+
path: book/pandoc/pdf/rust-course.pdf

book.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ copy-js = true
2121
[output.html.fold]
2222
enable = true
2323
level = 0
24+
25+
[output.pandoc]
26+
disabled = false
27+
28+
[output.pandoc.profile.pdf]
29+
output-file = "rust-course.pdf"
30+
pdf-engine = "tectonic"
31+
to = "pdf"
32+
variables = { mainfont = "Noto Sans CJK SC", sansfont = "Noto Sans CJK SC" }
33+
34+
[output.pandoc.profile.epub]
35+
output-file = "rust-course.epub"
36+
to = "epub3"

0 commit comments

Comments
 (0)