-
-
Notifications
You must be signed in to change notification settings - Fork 384
Add CI for PDF generation #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| name: Generate PDF using Pandoc (Docker) | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: null | ||
|
|
||
| jobs: | ||
| create_pdf: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: pandoc/latex:3 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: docker://pandoc/latex:3 | ||
| timeout-minutes: 10 | ||
| with: | ||
| entrypoint: './pandoc-docker.sh' | ||
|
|
||
| - id: short_sha | ||
| env: | ||
| GITHUB_SHA: ${{ github.sha }} | ||
| run: echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | ||
|
|
||
| - uses: softprops/action-gh-release@v3 | ||
| with: | ||
| tag_name: version-${{ steps.short_sha.outputs.short_sha }} | ||
| draft: false | ||
| files: | | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this and all related scripts below, pandoc configuration and so on to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to move things around. I'll include this in the update as well. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| \usepackage{enumitem} | ||
| \ifcsundef{c@none}{\newcounter{none}}{} | ||
| \setlistdepth{9} | ||
|
|
||
| \setlist[itemize,1]{label=$\bullet$} | ||
| \setlist[itemize,2]{label=$\bullet$} | ||
| \setlist[itemize,3]{label=$\bullet$} | ||
| \setlist[itemize,4]{label=$\bullet$} | ||
| \setlist[itemize,5]{label=$\bullet$} | ||
| \setlist[itemize,6]{label=$\bullet$} | ||
| \setlist[itemize,7]{label=$\bullet$} | ||
| \setlist[itemize,8]{label=$\bullet$} | ||
| \setlist[itemize,9]{label=$\bullet$} | ||
| \renewlist{itemize}{itemize}{9} | ||
|
|
||
| \setlist[enumerate,1]{label=$\arabic*.$} | ||
| \setlist[enumerate,2]{label=$\alph*.$} | ||
| \setlist[enumerate,3]{label=$\roman*.$} | ||
| \setlist[enumerate,4]{label=$\arabic*.$} | ||
| \setlist[enumerate,5]{label=$\alpha*$} | ||
| \setlist[enumerate,6]{label=$\roman*.$} | ||
| \setlist[enumerate,7]{label=$\arabic*.$} | ||
| \setlist[enumerate,8]{label=$\alph*.$} | ||
| \setlist[enumerate,9]{label=$\roman*.$} | ||
| \renewlist{enumerate}{enumerate}{9} | ||
|
|
||
| \usepackage{float} | ||
| \makeatletter | ||
| \let\origfigure\figure | ||
| \let\endorigfigure\endfigure | ||
| \renewenvironment{figure}[1][2]{% | ||
| \expandafter\origfigure\expandafter[H]% | ||
| }{% | ||
| \endorigfigure | ||
| } | ||
| \makeatother |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #! /bin/sh | ||
|
|
||
| # Install dependencies for successful PDF generation | ||
| for i in 1 2 3 4 5; do | ||
| tlmgr update --self && break | ||
| echo "tlmgr attempt $i failed, retrying in 5s..." | ||
| sleep 5 | ||
| done | ||
|
|
||
| for i in 1 2 3 4 5; do | ||
| tlmgr install collection-fontsrecommended ctex enumitem float \ | ||
| greek-fontenc koma-script polyglossia realscripts xltxtra && break | ||
| echo "tlmgr install attempt $i failed, retrying in 5s..." | ||
| sleep 5 | ||
| done | ||
|
|
||
| # Generate PDF using pandoc | ||
| for filename in pandoc-*yaml; do | ||
| # Create variable for language based on filename | ||
| language=$(echo "${filename}" | cut -d'.' -f1 | cut -d'-' -f2-3) | ||
|
|
||
| # Attempt to create the PDF | ||
| echo "Generating ${language} PDF..." | ||
| if pandoc -d "${filename}"; then | ||
| echo "Success! The ${language} PDF has been successfully created!" | ||
| else | ||
| echo "Failure! The ${language} PDF failed to be created!" | ||
| exit 1 | ||
| fi | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| metadata: | ||
| title: Introduction to the Assembly Programming Language | ||
| author: Alex Kuleshov | ||
| category: "License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License" | ||
| keywords: | ||
| - "assembly" | ||
| - "introduction" | ||
| standalone: true | ||
| variables: | ||
| documentclass: scrbook | ||
| lang: en-US | ||
| links-as-notes: true | ||
| lot: false | ||
| lof: false | ||
| margin-top: 1.27cm | ||
| margin-left: .635cm | ||
| margin-right: .635cm | ||
| margin-bottom: 1.27cm | ||
| table-of-contents: true | ||
| toc-depth: 2 | ||
| file-scope: true | ||
| from: markdown+rebase_relative_paths | ||
| include-in-header: include.tex | ||
| verbosity: ERROR | ||
| pdf-engine: xelatex | ||
| template: unicode.latex | ||
| input-files: | ||
| - ./content/asm_1.md | ||
| - ./content/asm_2.md | ||
| - ./content/asm_3.md | ||
| - ./content/asm_4.md | ||
| - ./content/asm_5.md | ||
| - ./content/asm_6.md | ||
| - ./content/asm_7.md | ||
| output-file: introduction-to-assembly.pdf | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #! /bin/bash | ||
|
|
||
| # Generate PDF using pandoc | ||
| generate_pdfs() { | ||
| for filename in pandoc-*yaml; do | ||
| # Create variable for language based on filename | ||
| IFS=- read _ language <<< "${filename}" | ||
| language=${language/.yaml/} | ||
|
|
||
| # Attempt to create the PDF | ||
| echo "Generating ${language} PDF..." | ||
| if pandoc -d "${filename}"; then | ||
| echo "Success! The ${language} PDF has been successfully created!" | ||
| else | ||
| echo "Failure! The ${language} PDF failed to be created!" | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Check for dependencies | ||
| check_dependencies () { | ||
| for dependency in "${dependencies[@]}" | ||
| do | ||
| if ! [ -x "$(command -v $dependency)" ]; then | ||
| echo "Error: $dependency is not installed." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| dependencies=("pandoc" "tex") | ||
|
|
||
| check_dependencies | ||
| generate_pdfs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not generate it at each possible commit/PR. I think the best way will be to build PDF by tags (I will push one right after we will merge the PR) but also leave sha-based builds but only for manual builds (based on workflow_dispatch).
Something like this (I did not test it although by myself yet):
@rcalixte what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean and I can work to implement this.