From 1e9d4a3c4a6ca29a0d19b74f19aaeff85d130973 Mon Sep 17 00:00:00 2001
From: Philip Bergmann <philip.bergmann@uni-wuerzburg.de>
Date: Mon, 27 Jan 2025 14:42:38 +0100
Subject: [PATCH] build the PDF via CI

---
 .gitlab-ci.yml | 18 +++++++++++++++++-
 build.sh       | 29 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 build.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 383ba39..29474f2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2024 Philip Bergmann <philip.bergmann@uni-wuerzburg.de>
+# SPDX-FileCopyrightText: 2024-2025 Philip Bergmann <philip.bergmann@uni-wuerzburg.de>
 # SPDX-License-Identifier: CC0-1.0
 
 default:
@@ -7,10 +7,26 @@ default:
   - linux
   - docker
 
+stages:
+  - lint
+  - build
+
 # Snippet from https://reuse.software/dev/
 reuse:
+  stage: lint
   image:
     name: fsfe/reuse:latest
     entrypoint: [""]
   script:
     - reuse lint
+
+build-as-is:
+  stage: build
+  image: registry.gitlab.com/islandoftex/images/texlive:latest
+  script:
+    - "./build.sh"
+  artifacts:
+    name: "$CI_PROJECT_NAME-job$CI_JOB_ID"
+    expire_in: "5 days"
+    paths:
+      - "writeup.pdf"
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..6aad3f2
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Builds the document using the 'current' documentclass configuration
+# SPDX-FileCopyrightText: 2025 Philip Bergmann <philip.bergmann@uni-wuerzburg.de>
+# SPDX-License-Identifier: CC0-1.0
+set -eu
+
+# Absolute path to $0's directory, resolving all symlinks in the path
+script_dir="$(dirname "$(readlink -f "$0")")"
+readonly script_dir
+cd -- "$script_dir"
+
+# Config: job name
+readonly default_jobname="writeup"
+readonly jobname="${jobname:-$default_jobname}"
+
+# latexmk sometimes has/had(?) problems with recognozing the source has changed
+# after a git checkout/... and therefore decidied no rebuild was needed
+# (even though it was!).
+# We solve this by always deleting the PDF before the latexmk call in build.sh
+rm -f -- "$jobname.pdf"
+
+# Increase latex max line length, this makes it easier to read the log
+# from https://tex.stackexchange.com/a/52994
+export max_print_line=1000
+export error_line=254
+export half_error_line=238
+
+# Run latexmk with the options specified in latexmkrc
+latexmk "$jobname"
-- 
GitLab