Update make-pdf-1-select.yml #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and Make eBook | |
# This workflow runs upon | |
# - push to main (check, make, publish) | |
# - create new PR (check, make) | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
# permissions: | |
# contents: read | |
jobs: | |
# | |
# check source code | |
# | |
check: | |
runs-on: ubuntu-24.04 | |
outputs: | |
cache-hit: ${{ steps.cache-lookup.outputs.cache-hit }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 # 0 if you want to push to repo | |
- name: Touch requirements.txt for pip caching | |
run: touch requirements.txt | |
- name: Calculate hash on chapters/*.tex | |
id: calculate-hash | |
run: | | |
current_date=$(date -u '+%Y-%m-%d') | |
hashed=${{ hashFiles('chapters/*.tex') }} | |
echo "hash=${current_date}-${hashed}" >> $GITHUB_OUTPUT | |
echo "${current_date}-${hashed}" > hash-chapters.txt | |
- name: Cache lookup | |
id: cache-lookup | |
uses: actions/cache@v4 | |
with: | |
path: hash-chapters.txt | |
key: chapter-hash-for-ebook-${{ steps.calculate-hash.outputs.hash }} | |
- name: Python set up | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
- name: Check chapters for known issues | |
run: python3 -O scripts/check_chapters.py | |
- name: Check pre-commit hooks | |
uses: pre-commit/[email protected] | |
# | |
# make eBook | |
# | |
make: | |
needs: check | |
# do not run for unchanged tex files | |
if: needs.check.outputs.cache-hit != 'true' | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 # 0 if you want to push to repo | |
- name: Python set up | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
# no package needed, so no caching | |
# cache: "pip" | |
# - name: setup environment to DE lang | |
# run: | | |
# cd /usr/share/locales | |
# sudo ./install-language-pack de_DE.UTF-8 | |
- name: ls before | |
run: | | |
pwd | |
ls -l | |
echo ${{ needs.check.outputs.cache-hit }} | |
- name: Install apt packages using cache | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: texlive-extra-utils pandoc calibre imagemagick ghostscript | |
version: 1.0 | |
# execute_install_scripts: true | |
- name: Install ImageMagick to fix caching issue | |
# since cache does not properly work / "convert" not found | |
run: | | |
sudo apt-get install imagemagick | |
- name: Print versions | |
run: | | |
cat /etc/os-release | |
# xelatex -v | |
# latexmk -v | |
calibre --version | |
pandoc --version | |
python3 --version | |
- name: Make eBooks | |
run: | | |
wget --quiet https://github.com/entorb/hpmor-de/releases/download/WorkInProgress/hpmor.pdf -O hpmor.pdf | |
sh scripts/make_ebooks.sh > /dev/null | |
- name: ls after | |
run: | | |
pwd | |
ls -l | |
- name: Publish eBooks to release | |
# run only for push into main | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: WorkInProgress | |
prerelease: true | |
files: | | |
./hpmor.docx | |
./hpmor.html | |
./hpmor.epub | |
./hpmor.mobi | |
./hpmor.fb2 |