Build LaTeX documents with the GitLab CI
For fun and reproduceability I set up a CI build for my LaTeX documents. I used it mainly for my thesis.
Overview
This guide is targeted on people who already have a GitLab Runner with Docker support up and running. I will not provide information on how to get there. This topic is covered by lots of other guides all over the internet.
I guess the main motivation for this is having a defined building environment without an IDE like TexStudio beeing involved and doing some parts of the job for you.
This starts with having a local Makefile or a sequence of bash commands to build the documents.
But first lets declare what packages must be available:
On my laptop I installed the texlive-full packages. In my experience it includes all dependecies you use in a normal use case.
Makefile
Next have a look at the Makefile I am using. I use latexmk inside to create the parts like blibliography and so on and the only seprate build object is the gloassary.
You can skip using a Makefile altogether if your use-case is simpler and you have just one or two bash comands.
|
|
CI-File
Finally there is the CI file itself.
All together my .gitlab-ci.yml:
|
|
Let’s take it apart:
|
|
I use submodules in my project, if you don’t, leave this out. It tells the Runner to checkout the submodules recirsively.
|
|
Above I discussed the build environemnt that is neccessary. This comand specifies a Docker image with the texlive-full installation. This is the largest image with about 5GB uncompressed. There are others available which may be enough for you and which are smaller.
If you do not want to use Docker you can als run this on GitLab Shell or SSH runners. You just have to install the texlive packages on those hosts by hand as a preliminary.
|
|
The actual build command. Make sure you change into the correct directoy before running make
or have the Makefile in the parent directory.
|
|
This advises the Runner to store the compiled pdf file with the GitLab artifacts. It allows you to download the pdf through the web frontend lateron.
In summary this may be a very simple example – but as always a lot of power comes with automation.