-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (149 loc) · 5.03 KB
/
Copy pathbuild.yml
File metadata and controls
174 lines (149 loc) · 5.03 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: build
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
env:
PANDOC_VERSION: "3.9.0.2"
TECTONIC_VERSION: "0.16.0"
NODE_VERSION: "20"
jobs:
build-pdf:
name: PDF (Pandoc + Tectonic)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Pandoc
id: cache-pandoc
uses: actions/cache@v4
with:
path: ~/.local/pandoc
key: pandoc-${{ env.PANDOC_VERSION }}-${{ runner.os }}
- name: Install Pandoc
if: steps.cache-pandoc.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.local/pandoc
curl -fsSL \
"https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz" \
| tar xz -C ~/.local/pandoc --strip-components=1
- name: Cache Tectonic
id: cache-tectonic
uses: actions/cache@v4
with:
path: ~/.local/bin/tectonic
key: tectonic-${{ env.TECTONIC_VERSION }}-${{ runner.os }}
- name: Install Tectonic
if: steps.cache-tectonic.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.local/bin
curl -fsSL \
"https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic@${TECTONIC_VERSION}/tectonic-${TECTONIC_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar xz -C ~/.local/bin
- name: Install fonts
run: |
sudo apt-get update -qq
sudo apt-get install -y fonts-dejavu fonts-dejavu-core fonts-liberation
fc-cache -f
fc-list | grep -iE 'dejavu|liberation' | head -5
- name: Swap mac fonts for Linux substitutes
# GitHub runners don't have macOS Charter / Helvetica / Menlo.
# Substitute with DejaVu (ships with fonts-dejavu, always
# available); the committed metadata.yaml stays mac-friendly.
run: |
sed -i \
-e 's/^mainfont:.*/mainfont: "DejaVu Serif"/' \
-e 's/^sansfont:.*/sansfont: "DejaVu Sans"/' \
-e 's/^monofont:.*/monofont: "DejaVu Sans Mono"/' \
-e '/^mainfontoptions:/,/^[^ ]/{/Numbers=OldStyle/d}' \
metadata.yaml
grep -E '^(mainfont|sansfont|monofont):' metadata.yaml
- name: Build PDF
run: |
export PATH="$HOME/.local/pandoc/bin:$HOME/.local/bin:$PATH"
pandoc --version | head -1
tectonic -X --help >/dev/null && echo "tectonic OK"
./build.sh
- name: Upload PDF artifact
uses: actions/upload-artifact@v4
with:
name: pdf
path: build/r3vbook.pdf
if-no-files-found: error
build-html:
name: HTML (VitePress)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: web/package.json
- name: Build HTML
run: ./scripts/build-html.sh
- name: Upload HTML artifact
uses: actions/upload-artifact@v4
with:
name: html
path: web/dist/
if-no-files-found: error
deploy-pages:
name: Deploy HTML to GitHub Pages
needs: build-html
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Download HTML artifact
uses: actions/download-artifact@v4
with:
name: html
path: site/
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
publish_branch: gh-pages
commit_message: "deploy: ${{ github.sha }}"
release:
name: Create GitHub Release
needs: [build-pdf, build-html]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download PDF
uses: actions/download-artifact@v4
with:
name: pdf
path: ./
- name: Download HTML
uses: actions/download-artifact@v4
with:
name: html
path: html/
- name: Package release artifacts
run: |
tag="${GITHUB_REF_NAME}"
zip -qr "practical-reverse-engineering-${tag}-html.zip" html/
mv r3vbook.pdf "practical-reverse-engineering-${tag}.pdf"
ls -la *.pdf *.zip
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body_path: CHANGELOG.md
draft: false
prerelease: false
files: |
practical-reverse-engineering-${{ github.ref_name }}.pdf
practical-reverse-engineering-${{ github.ref_name }}-html.zip