Added a build script
Some checks failed
Build Typst PDFs (Docker) / build-typst (push) Failing after 31s

This commit is contained in:
alexander
2025-12-14 16:36:05 +01:00
parent 5a7e4764cc
commit 9bba9a337a
4 changed files with 214 additions and 8 deletions

View File

@@ -1,11 +1,30 @@
#!/bin/bash
#!/usr/bin/env bash
# Find all .typ files under src/ (recursive) into an array
mapfile -d '' LIST_OF_TYPST_FILES < <(find src -maxdepth 1 -type f -name '*.typ' -print0)
set -euo pipefail
SRC_DIR="${TYPST_SOURCE_DIR}"
OUT_DIR="${BUILD_DIR}"
rm -rf output
mkdir -p output
if [[ ! -d "$SRC_DIR" ]]; then
echo "Source directory '$SRC_DIR' does not exist."
exit 1
fi
for FILE in "${LIST_OF_TYPST_FILES[@]}"; do
typst compile "$FILE" output/"$(basename "${FILE%.*}").pdf"
done
mkdir -p "$OUT_DIR"
# Find all .typ files under $SRC_DIR (excluding hidden dirs)
mapfile -d '' files < <(printf '%s\0' "$SRC_DIR"/*.typ 2>/dev/null)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No .typ files found in '$SRC_DIR'."
exit 0
fi
for f in "${files[@]}"; do
# Trim leading ./ if present
rel="${f#./}"
# Destination path: build/<same-subdirs>/<filename>.pdf
dest_pdf="${OUT_DIR}/$(basename "${rel%.typ}").pdf"
echo "Compiling: $f -> $dest_pdf"
typst compile "$f" "$dest_pdf"
done