Skip to content

Commit 82bf9cd

Browse files
authored
Auto-compilation action (#2)
* Add action to compile typst documents into PDFs * more specific artifact name
1 parent 48970d2 commit 82bf9cd

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎.github/workflows/compile.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Compile into PDFs
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
name: Compile into PDFs
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v5
13+
14+
- name: Install Typst
15+
uses: typst-community/setup-typst@v5
16+
17+
- name: Build PDFs
18+
run: |
19+
chmod +x compile.sh
20+
./compile.sh
21+
22+
- name: Upload PDFs
23+
uses: actions/upload-artifact@v7
24+
with:
25+
name: init-documents
26+
path: build/

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

‎compile.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
find . -name "*.typ" ! -wholename "./templates/*" -print0 | while IFS= read -r -d '' file; do
4+
rel="${file#./}"
5+
output="./build/${rel%.typ}.pdf"
6+
echo "Compiling $file to $output"
7+
# Create all parent directories
8+
mkdir -p "$(dirname "$output")"
9+
# Compile
10+
typst compile \
11+
--root . \
12+
--ignore-system-fonts \
13+
--font-path assets/fonts/ \
14+
--format pdf \
15+
"$file" "$output"
16+
done

0 commit comments

Comments
 (0)