Skip to content

Commit

Permalink
Merge pull request #8 from Die-KoMa/ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
mmarx authored Nov 1, 2024
2 parents 90d9b75 + de48f5a commit 4099747
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 14 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Build Berufungshandbuch"
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
name: "Build the Neulingsheft PDF"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v9
with:
nix-installer-tag: v0.15.1
- uses: DeterminateSystems/magic-nix-cache-action@v3
- env:
BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }}
run: echo "name=BRANCH_NAME::${BRANCH_NAME_OR_REF#refs/heads/}" >> $GITHUB_ENV
- run: echo "name=PR_NUMBER::$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")" >> $GITHUB_ENV
- run: nix --print-build-logs build .#neulingsheft -o neulingsheft.pdf
- uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: neulingsheft.pdf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ main.pdf
# files generated by latexmk
*.fls
*.fdb_latexmk

\#*#
*~
/auto/
/result
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
description = "Neulingsheft";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
};

outputs =
inputs@{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };

environment = {
TEXMFHOME = ".cache";
TEXMFVAR = ".cache/texmf-var";
SOURCE_DATE_EPOCH = toString self.lastModified;
};

texlive = pkgs.texlive.combine {
inherit (pkgs.texlive)
babel
collection-fontsrecommended
collection-langgerman
colorprofiles
csquotes
draftwatermark
ec
hyperref
koma-script
latex-bin
latexmk
mathtools
metafont
microtype
pdfmanagement-testphase
pdfx
scheme-basic
silence
textpos
titlesec
todonotes
wasysym
xkeyval
xmpincl
xstring
;
};

mkDocument =
name:
pkgs.stdenvNoCC.mkDerivation rec {
inherit name;
src = self;

allowSubstitutes = false;
buildInputs = [
pkgs.coreutils
pkgs.gawk
texlive
];
phases = [
"unpackPhase"
"buildPhase"
"installPhase"
];
buildPhase = ''
runHook preBuild
export PATH="${pkgs.lib.makeBinPath buildInputs}";
mkdir -p .cache/texmf-var
env TEXMFHOME=${environment.TEXMFHOME} \
TEXMFVAR=${environment.TEXMFVAR} \
SOURCE_DATE_EPOCH=${environment.SOURCE_DATE_EPOCH} \
latexmk -interaction=nonstopmode -pdf \
${name}.tex
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp ${name}.pdf $out
runHook postInstall
'';
};

in
{
packages."${system}" = rec {
default = neulingsheft;
neulingsheft = mkDocument "main";
};

devShells."${system}".default = pkgs.mkShell {
inherit (environment) TEXMFHOME TEXMFVAR SOURCE_DATE_EPOCH;
buildInputs = [ texlive ];
};
};
}
31 changes: 17 additions & 14 deletions neulingsheft.cls
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
\RequirePackage[ngerman]{babel}
% Names and hyphenation rules for German.
% UTF-8 encoding (not necessary for LuaTeX)
\RequirePackage[utf8x]{inputenc} % Allow input of arbitrary characters.
\RequirePackage[utf8]{inputenc} % Allow input of arbitrary characters.
%\RequirePackage[T1]{fontenc} % Allow hyphenation in words with non-ASCII characters
\RequirePackage{microtype} % Improved typography, removes some overfull \hboxes.
\RequirePackage{hyperref} % Adds links and bookmarks to PDF.
\RequirePackage{csquotes} % allow enquote instead of unicode
%===Start happy hacking===%

% reproducible documents
\pdftrailerid{}
% ===Start happy hacking===%
\makeatletter

%===Document Metadata===%
Expand Down Expand Up @@ -45,7 +48,7 @@
% it is actually available (ie. in pdftex >=1.40.15). Especially luatex does
% not have this problem at all (and thus no option to suppress the warnings).
\ifdefined\pdfsuppresswarningpagegroup
\pdfsuppresswarningpagegroup=1
\pdfsuppresswarningpagegroup=1
\fi
%==Code Listings==%
%\RequirePackage{listings}
Expand All @@ -61,18 +64,18 @@
% .05\linewidth setzt es das Bild (oben bündig mit der Überschrift) in einem
% .25\linewidth breiten Bereich zentriert mit einer Breite von #1.
\newenvironment{handzeichen}[3][.25\linewidth]{% [Bildbreite], Name, Bild
\def\handzeichen@width{#1}%
\def\handzeichen@img{#3}%
\noindent
\begin{minipage}[t]{.7\linewidth}%
\section*{#2}%
\def\handzeichen@width{#1}%
\def\handzeichen@img{#3}%
\noindent
\begin{minipage}[t]{.7\linewidth}%
\section*{#2}%
}{%
\end{minipage}%
\hspace{.05\linewidth}%
\makebox[.25\linewidth]{\raisebox{-\height}{%
\includegraphics[width=\handzeichen@width]{\handzeichen@img}%
}}%
\medskip
\end{minipage}%
\hspace{.05\linewidth}%
\makebox[.25\linewidth]{\raisebox{-\height}{%
\includegraphics[width=\handzeichen@width]{\handzeichen@img}%
}}%
\medskip
}

%===Stop happy hacking===%
Expand Down

0 comments on commit 4099747

Please sign in to comment.