Skip to content

Commit

Permalink
Lua logic & automation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pelasgus committed Jul 3, 2024
1 parent 179f6db commit eae1aaa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/pdf-production.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
name: Compile PDF
name: Compile LaTeX document
on: [push]
jobs:
compile_latex:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v4

- name: Extract PDF name from LaTeX title
run: |
sudo apt-get install -y lua5.3
lua logic/logic.lua main.tex > pdf_name.txt
echo "PDF_NAME=$(cat pdf_name.txt)" >> $GITHUB_ENV
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v3
with:
root_file: main.tex
- name: Upload PDF file
latexmk_use_xelatex: true

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: main.pdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload PDF to Release
uses: actions/upload-artifact@v4
with:
name: PDF
name: ${{ env.PDF_NAME }}
path: main.pdf
- name: Produce a Release that includes the final PDF file.
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: main.pdf
22 changes: 22 additions & 0 deletions logic/logic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- logic/logic.lua
local file = io.open(arg[1], "r")
local title = nil

if file then
for line in file:lines() do
local match = string.match(line, "\\title{(.+)}")
if match then
title = match
break
end
end
file:close()
end

if title then
-- Remove non-alphanumeric characters and replace spaces with underscores
title = title:gsub("[^%w%s]", ""):gsub("%s+", "_")
print(title .. ".pdf")
else
print("document.pdf")
end
2 changes: 2 additions & 0 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#+AUTHOR: D.A.Pelasgus

- This is a highly opinionated Latex template.
- The temaplate makes use of lualatex.
- A lua script extracts the title from the latex project; its used as the final pdfs name.
- To use this template either clone the repository or click on the /use this template button/.
- Navigate to /setup/variables.tex/ for credetials' declaration.
- On *Git Push*, a PDF artefact shall be generated, available under the actions tab.

0 comments on commit eae1aaa

Please sign in to comment.