Skip to content
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

Add GitHub Action to convert Releasenotes.md to PDF #58

Merged
merged 13 commits into from
Sep 11, 2024
Merged
14 changes: 14 additions & 0 deletions .github/scripts/md2pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# md2pdf.py
#
# Carl Zeiss GOM Metrology GmbH, 2024
#
# ---
'''Convert Markdown document to PDF'''
import sys
from markdown_pdf import MarkdownPdf, Section

pdf = MarkdownPdf(toc_level=4)
pdf.add_section(Section(open(sys.argv[1], encoding='utf-8').read(), toc=False), user_css="body {font-family: sans-serif;}")
pdf.meta["title"] = "Releasenotes"
pdf.save(sys.argv[2])
18 changes: 10 additions & 8 deletions .github/workflows/releasenotes_pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Pandoc
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install markdown_pdf
run: |
sudo apt-get update
# Install pdflatex as prerequisite for pandoc PDF output
sudo apt-get install -y texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
sudo apt-get install -y pandoc

pip install markdown_pdf

- name: Find and Convert Release Notes
id: convert_notes
run: |
Expand All @@ -29,11 +31,11 @@ jobs:
basepath=$(dirname "{}") # Get the folder path
echo $basepath
if [ ! -f "$basepath/Releasenotes.pdf" ]; then
pandoc --variable mainfont="Arial" "{}" -o "$basepath/Releasenotes.pdf"
python .github/scripts/md2pdf.py "{}" "$basepath/Releasenotes.pdf"
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git add "$basepath/Releasenotes.pdf"
git commit -m "Add Releasenotes.pdf"
git push origin main
git push origin ${GITHUB_REF#refs/*/}
fi
' \;
Binary file modified AppExamples/dialog_widgets/DropdownWidget/doc/Releasenotes.pdf
Binary file not shown.
Binary file modified AppExamples/script_resources/ResourceAccess/doc/Releasenotes.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.