A GitHub Action that compiles all LaTeX documents in one shot, automatically, with minimal configuration, using (by default) the great Rubber toolchain.
This action is meant to be as portable as possible, namely, it is meant to be written once and then delivered to multiple repositories with no changes (e.g., via Autodelivery).
To this end, this action scans your file system, searching for .tex
files.
Unless a file has a magic comment similar to % ! TeX root = ...
,
then it is interpreted as a LaTeX root document and its compilation is attempted.
If the magic comment is found, then the value of the magic comment is also added to the list of files to be compiled.
A list of compiled files is produced and stored in the LATEX_SUCCESSES
multi-line environment variable,
so that it can easily be used to deploy them wherever you see fit.
Also, two GitHub Actions outputs are produced:
successfully-compiled
, a comma-separated list of all successfully compiled filescompiled-files
, a comma-separated list of all the produced pdfs
These are particularly handy if the files are to be published with ncipollo/release-action
In the following examples, we show a workflow using this action to compile all tex
files, and then deploying them as pdfs on GitHub Releases via hub
.
The version is generated by the SemVer Autotag action.
name: Build LaTeX and deploy on GH Releases
on:
push:
jobs:
Build-LaTeX:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch tags
shell: bash
run: git fetch --tags -f
- name: Compile LaTeX
# PICK A FIXED VERSION! I do work on master sometimes!
uses: DanySK/compile-latex-action@master
- name: Autotag
uses: DanySK/semver-autotag-action@master
- name: Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=$(git describe --tags --exact-match HEAD)
hub release create -m "$(git tag -l --format='%(contents)' "$TAG")" "$TAG" || true
for file in $LATEX_SUCCESSES; do
pdf="${file%.*}.pdf"
echo "Delivering file $pdf"
gh release upload "$TAG" "$pdf" --clobber
done