112 lines
3.5 KiB
YAML
112 lines
3.5 KiB
YAML
name: LaTeX Diff
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
base_branch:
|
|
description: 'Base branch (older version)'
|
|
required: true
|
|
compare_branch:
|
|
description: 'Compare branch (new version)'
|
|
required: true
|
|
|
|
jobs:
|
|
latexdiff:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/xu-cheng/texlive-full:latest
|
|
options: --user root
|
|
|
|
steps:
|
|
- name: Install latexpand (Perl script)
|
|
run: |
|
|
tlmgr init-usertree
|
|
tlmgr install latexpand
|
|
|
|
- name: Checkout base branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.base_branch }}
|
|
path: base
|
|
|
|
- name: Checkout compare branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.inputs.compare_branch }}
|
|
path: compare
|
|
|
|
|
|
- name: Create output folder
|
|
run: mkdir -p diff_output
|
|
|
|
- name: Flatten base/main.tex (with latexpand)
|
|
run: |
|
|
cd base/latex
|
|
echo "📂 Listing files in base/latex:"
|
|
ls -R
|
|
echo "🔄 Flattening with latexpand..."
|
|
latexpand --verbose --keep-comments --output=../../diff_output/base_flat.tex main.tex
|
|
echo "✅ Preview of base_flat.tex:"
|
|
head -n 50 ../../diff_output/base_flat.tex
|
|
|
|
|
|
- name: Flatten compare/main.tex (with latexpand)
|
|
run: |
|
|
cd compare/latex
|
|
echo "📂 Listing files in compare/latex:"
|
|
ls -R
|
|
echo "🔄 Flattening with latexpand..."
|
|
latexpand --verbose --keep-comments --output=../../diff_output/compare_flat.tex main.tex
|
|
echo "✅ Preview of compare_flat.tex:"
|
|
head -n 50 ../../diff_output/compare_flat.tex
|
|
|
|
- name: Generate diff.tex using latexdiff
|
|
run: |
|
|
latexdiff diff_output/base_flat.tex diff_output/compare_flat.tex > diff_output/diff.tex
|
|
|
|
- name: Upload flattened .tex and diff.tex early
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: latex-diff-tex
|
|
path: |
|
|
diff_output/base_flat.tex
|
|
diff_output/compare_flat.tex
|
|
diff_output/diff.tex
|
|
|
|
- name: Copy thesis.cls to diff_output
|
|
run: cp compare/latex/thesis.cls diff_output/
|
|
|
|
- name: Override “\input{preamble/fonts}” in diff.tex
|
|
run: |
|
|
sed -i '/\\input{preamble\/fonts}/c\
|
|
% — replaced by CI: use TeX Gyre fonts instead of Times New Roman/Arial \
|
|
\setmainfont{TeX Gyre Termes} \
|
|
\setsansfont{TeX Gyre Heros} \
|
|
\setmonofont{TeX Gyre Cursor}\
|
|
' diff_output/diff.tex
|
|
|
|
- name: Print preview of diff.tex (after font override)
|
|
run: |
|
|
echo "📄 Preview of diff_output/diff.tex after font override:"
|
|
head -n 50 diff_output/diff.tex
|
|
|
|
- name: Compile diff.tex to PDF
|
|
working-directory: diff_output
|
|
continue-on-error: true
|
|
run: |
|
|
xelatex -interaction=nonstopmode diff.tex
|
|
xelatex -interaction=nonstopmode diff.tex
|
|
|
|
|
|
- name: Compile diff.tex to PDF
|
|
working-directory: diff_output
|
|
run: |
|
|
xelatex -interaction=nonstopmode diff.tex
|
|
xelatex -interaction=nonstopmode diff.tex
|
|
|
|
- name: Upload diff output files
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: latex-diff-output
|
|
path: diff_output/
|