1- # This workflow builds PDFs and eBooks upon push of new commits.
2- # Generated assets are uploaded to release WorkInProgress.
1+ # This workflow performs
2+ # check: Quality checks on chapter text and code upon new commits and PRs.
3+ # make: Makes PDFs and eBooks if .tex files have changed.
4+ # upload: Uploads the artifacts to release WorkInProgress, but only for push into main branch.
35
4- name : Build HPMOR PDFs and eBooks
6+ name : Check and Make
7+
8+ # This workflow runs upon
9+ # - manual triggering
10+ # - create new PR (check, make)
11+ # - push to main (check, make, upload)
512
613on :
7- workflow_dispatch : # manual triggering
14+ workflow_dispatch :
15+ pull_request :
16+ branches : ["main"]
817 push :
9- branches : [main]
18+ branches : [" main" ]
1019
1120jobs :
12- build :
21+ check :
22+ runs-on : ubuntu-24.04
23+ outputs :
24+ cache-hit : ${{ steps.cache-lookup.outputs.cache-hit }}
25+
26+ steps :
27+ - name : Checkout repository
28+ uses : actions/checkout@v4
29+ with :
30+ persist-credentials : false
31+ fetch-depth : 1 # 0 if you want to push to repo
32+
33+ - name : Calculate hash on chapters/*.tex
34+ id : calculate-hash
35+ run : |
36+ echo "hash=${{ hashFiles('chapters/*.tex') }}" >> $GITHUB_OUTPUT
37+ touch hash-chapters.txt
38+
39+ - name : Cache lookup
40+ id : cache-lookup
41+ uses : actions/cache@v4
42+ with :
43+ path : hash-chapters.txt
44+ key : chapter-hash-for-ebook-${{ github.ref_name }}-${{ steps.calculate-hash.outputs.hash }}
45+
46+ - name : Preparations
47+ run : ln -s python-requirements.txt requirements.txt
48+
49+ - name : Python set up
50+ uses : actions/setup-python@v5
51+ with :
52+ python-version : " 3.12"
53+ cache : " pip"
54+
55+ - name : Check chapters for known issues
56+ run : python3 -O scripts/check_chapters.py
57+
58+ - name : Check pre-commit tests
59+ uses :
pre-commit/[email protected] 60+
61+ make :
62+ needs : check
63+ # do not run for unchanged tex files
64+ if : needs.check.outputs.cache-hit != 'true'
65+
1366 runs-on : ubuntu-24.04
1467
1568 steps :
@@ -42,26 +95,16 @@ jobs:
4295 python-version : " 3.12"
4396 cache : " pip"
4497
45- # - name: test ls before
46- # run: |
47- # pwd
48- # ls -al
49-
50- - name : Check chapters for known issues
51- run : python3 scripts/check_chapters.py
52-
53- - name : Check pre-commit tests
54- uses :
pre-commit/[email protected] 55-
56- - name : Install requirements
98+ - name : Install requirements (apt and python)
5799 run : sh scripts/install_requirements.sh > /dev/null
58100
59101 - name : Print versions
60102 run : |
61103 cat /etc/os-release
62104 xelatex -v
63105 latexmk -v
64- pandoc -v
106+ calibre --version
107+ pandoc --version
65108 ebook-convert --version
66109 python3 --version
67110
80123 diff -u -s hpmor-prev.html hpmor.html > hpmor-html-diff.log || :
81124 rm hpmor-prev.html
82125
83- - name : Test ls after
126+ - name : ls after
84127 run : |
85128 pwd
86129 ls -al
@@ -92,11 +135,29 @@ jobs:
92135 path : |
93136 ./hpmor-html-diff.log
94137 ./hpmor.epub
138+ ./hpmor.fb2
95139 ./hpmor.html
140+ ./hpmor.mobi
96141 ./hpmor.pdf
97142 retention-days : 14
98143
99- - name : Upload files to release WorkInProgress
144+ #
145+ # upload to release WorkInProgress
146+ #
147+ upload :
148+ needs : make
149+ # only for push into main branch
150+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
151+
152+ runs-on : ubuntu-24.04
153+
154+ steps :
155+ - name : Download eBooks artifact
156+ uses : actions/download-artifact@v4
157+ with :
158+ name : ebooks
159+
160+ - name : Publish eBooks to release WorkInProgress
100161 uses : softprops/action-gh-release@v2
101162 with :
102163 tag_name : WorkInProgress
0 commit comments