Skip to content

Commit

Permalink
implement git support
Browse files Browse the repository at this point in the history
add support for gitinfo2 #5
  • Loading branch information
prudhomm committed Aug 4, 2024
1 parent 53aca10 commit 74fbd64
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

name: Compile Latex and Release PDF
name: Compile Latex and Release PDF


on:
Expand All @@ -8,8 +8,8 @@ on:
- 'v*'
branches:
- '*'


jobs:
build_latex:
runs-on: ubuntu-latest
Expand All @@ -20,21 +20,25 @@ jobs:
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Install hooks
run: |
sh ./setup-hooks.sh
git checkout
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v3
with:
root_file: main.tex
latexmk_shell_escape: true
post_compile: "latexmk -c; rm -rf _minted*"

- name: Get Repository Name
id: repo_name
run: |
ls -lrt
prefix=$(echo "${{ github.repository }}" | cut -d'/' -f2)
echo "prefix=$prefix" >> "$GITHUB_OUTPUT"
echo "pdf=$prefix-${{ github.ref_name }}.pdf" >> "$GITHUB_OUTPUT"
-
-
name: Rename PDF
run: |
mv main.pdf ${{ steps.repo_name.outputs.pdf }}
Expand All @@ -45,7 +49,7 @@ jobs:
name: PDF
path: ${{ steps.repo_name.outputs.pdf }}

-
-
name: Create Release
id: create_release
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
33 changes: 33 additions & 0 deletions hooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
# Copyright 2015 Brent Longborough
# Part of gitinfo2 package Version 2
# Release 2.0.7 2015-11-22
# Please read gitinfo2.pdf for licencing and other details
# -----------------------------------------------------
# Post-{commit,checkout,merge} hook for the gitinfo2 package
#
# Get the first tag found in the history from the current HEAD
FIRSTTAG=$(git describe --tags --always --dirty='-*' 2>/dev/null)
# Get the first tag in history that looks like a Release
RELTAG=$(git describe --tags --long --always --dirty='-*' --match 'v[0-9]*\.[0-9]*\.[0-9]*' 2>/dev/null)
# Hoover up the metadata
git --no-pager log -1 --date=short --decorate=short \
--pretty=format:"\usepackage[%
shash={%h},
lhash={%H},
authname={%an},
authemail={%ae},
authsdate={%ad},
authidate={%ai},
authudate={%at},
commname={%cn},
commemail={%ce},
commsdate={%cd},
commidate={%ci},
commudate={%ct},
refnames={%d},
firsttagdescribe={$FIRSTTAG},
reltag={$RELTAG}
]{gitexinfo}" HEAD > .git/gitHeadInfo.gin

cp .git/gitHeadInfo.gin gitHeadLocal.gin
19 changes: 15 additions & 4 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{hyperref}
\IfFileExists{.git/gitHeadInfo.gin}{
\usepackage[pcount,grumpy,mark,markifdirty]{gitinfo2}
}{%
\usepackage[local,pcount,grumpy,mark,markifdirty]{gitinfo2}
}

\usepackage[bookmarksnumbered,bookmarksopen,linktocpage]{hyperref}

\usepackage{minted}
\usepackage{natbib}

\CatchFileDef{\myversion}{|echo $VERSION}{}

\title{Template Repository for Articles}
\author{Christophe Prud'homme\thanks{Cemosis, IRMA UMR 7501, Université de Strasbourg, CNRS, France, \tt \href{mailto:[email protected]}{[email protected]}}}
\date{\gitReln\ \gitAuthorDate\ (\gitAbbrevHash)}

% Define custom color
\definecolor{CustomBlue}{rgb}{0.25, 0.41, 0.88} % RoyalBlue
% Set up hyperref with the custom citecolor
\hypersetup{
pdftitle={\@title},
pdfauthor={\@author},
pdfsubject={\@subject},
pdfkeywords={mathematical and computational ophthalmology, finite element method, thermo-fluid dynamics, feelpp},
colorlinks=true,
citecolor=CustomBlue,
linkcolor=black, % You can set this to any color you prefer
Expand Down Expand Up @@ -41,8 +54,6 @@

\begin{document}

\title{Template Repository for Articles\\ \small\tt Version \myversion}
\author{Christophe Prud'homme\thanks{Cemosis, IRMA UMR 7501, Université de Strasbourg, CNRS, France, \tt \href{mailto:[email protected]}{[email protected]}}}
\maketitle
\tableofcontents

Expand Down
7 changes: 7 additions & 0 deletions setup-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh


for i in commit checkout merge; do
cp hooks/post-commit .git/hooks/post-$i
chmod +x .git/hooks/post-$i
done

0 comments on commit 74fbd64

Please sign in to comment.