mirror of
https://github.com/NotXia/unibo-ai-notes.git
synced 2025-12-15 02:52:22 +01:00
Update compilation workflow
This commit is contained in:
21
.github/workflows/compile.yml
vendored
21
.github/workflows/compile.yml
vendored
@ -17,29 +17,28 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Checkout current pdfs branch
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: pdfs
|
||||||
|
path: .currpdfs
|
||||||
|
|
||||||
|
|
||||||
- name: Install LaTeX
|
- name: Install LaTeX
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y latexmk texlive texlive-science texlive-latex-extra
|
sudo apt install -y latexmk texlive texlive-science texlive-latex-extra
|
||||||
|
|
||||||
|
|
||||||
- name: Checkout old pdfs
|
- name: Prepare output directory
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: pdfs
|
|
||||||
path: .compiled
|
|
||||||
|
|
||||||
- name: Copy basic files to pdfs branch
|
|
||||||
run: |
|
run: |
|
||||||
|
mkdir .compiled
|
||||||
cp README.md .compiled
|
cp README.md .compiled
|
||||||
cp LICENSE .compiled
|
cp LICENSE .compiled
|
||||||
|
|
||||||
|
|
||||||
- name: Compile
|
- name: Compile
|
||||||
run: |
|
run: |
|
||||||
export LANG="en_GB.UTF-8"
|
bash ./compile.sh .compiled .currpdfs
|
||||||
export LC_ALL="en_GB.UTF-8"
|
|
||||||
bash ./compile.sh .compiled
|
|
||||||
|
|
||||||
|
|
||||||
- name: Move to pdfs branch
|
- name: Move to pdfs branch
|
||||||
|
|||||||
15
compile.sh
15
compile.sh
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Commit based .tex compiling
|
# Commit based .tex compiling
|
||||||
|
# $1 is the output directory.
|
||||||
|
# $2 is the directory of the current state of the files.
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
@ -12,7 +14,9 @@ fi
|
|||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
out_dir=`realpath $1`
|
out_dir=`realpath $1`
|
||||||
hash_file="$out_dir/.hash"
|
old_out_dir=`realpath $2`
|
||||||
|
hash_file="$old_out_dir/.hash"
|
||||||
|
new_hash_file="$out_dir/.hash"
|
||||||
work_dir=`realpath src`
|
work_dir=`realpath src`
|
||||||
|
|
||||||
mkdir -p $out_dir
|
mkdir -p $out_dir
|
||||||
@ -26,10 +30,10 @@ getDirLastHash () {
|
|||||||
|
|
||||||
updateHashes() {
|
updateHashes() {
|
||||||
cd $work_dir
|
cd $work_dir
|
||||||
echo "ainotes.cls,`git log -n 1 --format='%h' ./ainotes.cls`" > $hash_file
|
echo "ainotes.cls,`git log -n 1 --format='%h' ./ainotes.cls`" > $new_hash_file
|
||||||
for f in **/[!_]*.tex; do
|
for f in **/[!_]*.tex; do
|
||||||
f_dir=$(dirname $f)
|
f_dir=$(dirname $f)
|
||||||
echo "$f_dir,`git log -n 1 --format='%h' $f_dir`" >> $hash_file
|
echo "$f_dir,`git log -n 1 --format='%h' $f_dir`" >> $new_hash_file
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,13 +50,15 @@ for f in **/[!_]*.tex; do
|
|||||||
old_hash=`getDirLastHash "$f_dir"`
|
old_hash=`getDirLastHash "$f_dir"`
|
||||||
curr_hash="$(git log -n 1 --format='%h' $f_dir)"
|
curr_hash="$(git log -n 1 --format='%h' $f_dir)"
|
||||||
|
|
||||||
|
mkdir -p $out_dir/$f_dir
|
||||||
|
|
||||||
# Nothing to update
|
# Nothing to update
|
||||||
if [[ $old_hash == $curr_hash && $old_class_hash == $curr_class_hash ]]; then
|
if [[ $old_hash == $curr_hash && $old_class_hash == $curr_class_hash ]]; then
|
||||||
echo "Skipping $f_dir"
|
echo "Skipping $f_dir"
|
||||||
|
cp -r $old_out_dir/$f_dir/. $out_dir/$f_dir
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
cd ${f_dir};
|
cd ${f_dir};
|
||||||
|
|
||||||
# Insert last update date
|
# Insert last update date
|
||||||
@ -61,7 +67,6 @@ for f in **/[!_]*.tex; do
|
|||||||
sed -i "s/PLACEHOLDER-LAST-UPDATE/${last_update}/" ainotes.cls
|
sed -i "s/PLACEHOLDER-LAST-UPDATE/${last_update}/" ainotes.cls
|
||||||
|
|
||||||
latexmk -pdf -jobname=${f_nameonly} ${f_base}
|
latexmk -pdf -jobname=${f_nameonly} ${f_base}
|
||||||
mkdir -p $out_dir/$f_dir
|
|
||||||
mv ${f_nameonly}.pdf $out_dir/${f_dir}/.
|
mv ${f_nameonly}.pdf $out_dir/${f_dir}/.
|
||||||
cd $work_dir
|
cd $work_dir
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user