From 3cd5df39165c36bc5be03f661e13590dac83e153 Mon Sep 17 00:00:00 2001 From: Qun Liu Date: Fri, 12 Dec 2025 10:17:56 +0800 Subject: [PATCH] Add github workflow to compile tex files automatically with Tectonic and Biber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Compile all root-level .tex files containing "正文" using Tectonic - Automatically resolve references via Biber - Upload generated PDFs (e.g., 青年正文2025.pdf) as workflow artifacts --- .github/workflows/build_tex.yaml | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/build_tex.yaml diff --git a/.github/workflows/build_tex.yaml b/.github/workflows/build_tex.yaml new file mode 100644 index 0000000..658ba16 --- /dev/null +++ b/.github/workflows/build_tex.yaml @@ -0,0 +1,64 @@ +name: Build LaTeX with Tectonic + Biber + +on: + push: + branches: [ main ] + +jobs: + build-tex: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/cache@v3 + name: Tectonic Cache + with: + path: ~/.cache/Tectonic + key: ${{ runner.os }}-tectonic-${{ hashFiles('**/*.tex') }} + restore-keys: | + ${{ runner.os }}-tectonic- + + - uses: wtfjoke/setup-tectonic@v4 + with: + biber-version: "latest" + + - name: Find .tex files with "正文" in filename + id: find_tex + run: | + files=$(find . -maxdepth 1 -type f -name "*正文*.tex" | tr '\n' ' ') + if [ -z "$files" ]; then + echo "No .tex files containing '正文' found." + exit 1 + fi + echo "Found matching .tex files: $files" + echo "tex_files=$files" >> $GITHUB_OUTPUT + + - name: Compile each file with Tectonic with Biber + run: | + for texfile in ${{ steps.find_tex.outputs.tex_files }}; do + if [ -n "$texfile" ]; then + echo "Compiling $texfile with Tectonic + Biber..." + tectonic "$texfile" + fi + done + + - name: Collect generated PDFs + id: collect_pdfs + run: | + mkdir -p artifact_pdfs + for texfile in ${{ steps.find_tex.outputs.tex_files }}; do + pdf="${texfile%.tex}.pdf" + if [ -f "$pdf" ]; then + echo "PDF file: $pdf" + mv "$pdf" artifact_pdfs/ + fi + done + + - name: Upload compiled PDFs + uses: actions/upload-artifact@v4 + with: + name: compiled-pdfs + path: artifact_pdfs/ + if-no-files-found: error