forked from rrthomas/hpmor
-
Notifications
You must be signed in to change notification settings - Fork 6
134 lines (112 loc) · 3.38 KB
/
check-and-ebook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# This workflow runs upon new commits (check and make) and PRs (check only)
name: Check and Make eBook
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
# permissions:
# contents: read
jobs:
#
# check source code
#
check:
runs-on: ubuntu-22.04
outputs:
cache-hit: ${{ steps.cache-lookup.outputs.cache-hit }}
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1 # 0 if you want to push to repo
- 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.10"
# cache: "pip"
- name: python cache set up
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: python-${{ env.pythonLocation }}
- 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 make for pull_requests and not for unchanged tex files
if: github.event_name != 'pull_request' && needs.check.outputs.cache-hit != 'true'
runs-on: ubuntu-22.04
steps:
- name: checkout 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.10"
# 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: 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
uses: softprops/action-gh-release@v2
with:
tag_name: WorkInProgress
prerelease: true
files: |
./hpmor.docx
./hpmor.html
./hpmor.epub
./hpmor.mobi
./hpmor.fb2