Skip to content

Commit be302f6

Browse files
authored
Merge pull request #2 from omerssid/dev-rewrite-math-and-core-sections
Dev rewrite math and core perception sections
2 parents 1e34516 + 1984ea9 commit be302f6

10 files changed

Lines changed: 3492 additions & 35 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: build and release PDFs
2+
3+
# Pull requests build only, so a merge is never the first time this workflow runs
4+
# against a change. Pushes to main build and publish.
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
# The release step creates tags and releases.
13+
permissions:
14+
contents: write
15+
16+
# Per-ref, so a PR build and a main build never cancel each other. Within one ref,
17+
# superseding runs win: two merges in quick succession would otherwise race to move
18+
# the `latest` tag, and the older build is the one worth dropping.
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
pdf:
25+
runs-on: ubuntu-latest
26+
env:
27+
PANDOC_VERSION: "3.10.1"
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Install pandoc, XeLaTeX and fonts
33+
run: |
34+
# apt's pandoc is too old for --syntax-highlighting, so take the upstream deb.
35+
curl -fsSLO "https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-1-amd64.deb"
36+
sudo apt-get update
37+
sudo apt-get install -y \
38+
"./pandoc-${PANDOC_VERSION}-1-amd64.deb" \
39+
texlive-xetex texlive-latex-recommended texlive-latex-extra \
40+
fonts-texgyre fonts-texgyre-math fonts-dejavu-mono
41+
rm -f "pandoc-${PANDOC_VERSION}-1-amd64.deb"
42+
pandoc --version | head -1
43+
xelatex --version | head -1
44+
45+
# fontspec resolves the -V font names through fontconfig. If one is missing it
46+
# falls back silently in some cases, so check here rather than ship a PDF set in
47+
# the wrong typeface. Names must match tools/build.sh and tools/header.tex.
48+
- name: Verify fonts are visible to fontconfig
49+
run: |
50+
fc-cache -f > /dev/null
51+
for font in "TeX Gyre Pagella" "TeX Gyre Heros" "DejaVu Sans Mono" "TeX Gyre Pagella Math"; do
52+
if fc-list -f '%{family[0]}\n' | grep -qxF "$font"; then
53+
echo "ok: $font"
54+
else
55+
echo "::error::font not installed: $font"
56+
exit 1
57+
fi
58+
done
59+
60+
- name: Build PDFs
61+
run: |
62+
mkdir -p build
63+
for doc in perception-guide math-primer notation; do
64+
echo "::group::$doc.md"
65+
tools/build.sh "$doc.md" "build/$doc.pdf"
66+
echo "::endgroup::"
67+
done
68+
ls -lh build
69+
70+
# check.py is a heuristic linter and always exits 0 by design, so this is a
71+
# report on the job summary, not a gate on the release.
72+
- name: Linter report
73+
run: python3 tools/check.py >> "$GITHUB_STEP_SUMMARY"
74+
75+
# On a PR the PDFs are the check: download them from the run's Artifacts section.
76+
# Pushes to main skip this — the release below is the durable copy.
77+
- name: Upload PDFs as a build artifact
78+
if: github.event_name == 'pull_request'
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: pdfs
82+
path: build/*.pdf
83+
if-no-files-found: error
84+
retention-days: 14
85+
86+
- name: Publish rolling "latest" release
87+
if: github.event_name != 'pull_request'
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
run: |
91+
{
92+
echo "PDFs built from \`${GITHUB_SHA:0:7}\` on $(date -u '+%Y-%m-%d %H:%M UTC')."
93+
echo
94+
echo "Latest commit: $(git log -1 --pretty='%s')"
95+
} > "$RUNNER_TEMP/notes.md"
96+
97+
# Delete and recreate so the `latest` tag moves to this commit. The release
98+
# may not exist on the first run, hence the `|| true`.
99+
gh release delete latest --yes --cleanup-tag || true
100+
gh release create latest \
101+
--target "$GITHUB_SHA" \
102+
--title "Perception Handbook — latest build" \
103+
--notes-file "$RUNNER_TEMP/notes.md" \
104+
--latest \
105+
build/perception-guide.pdf \
106+
build/math-primer.pdf \
107+
build/notation.pdf

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__/
2+
*.pyc
3+
4+
build/

0 commit comments

Comments
 (0)