Skip to content

Instantly share code, notes, and snippets.

@MultisampledNight
Created April 12, 2024 07:10
Show Gist options
  • Save MultisampledNight/32fdd881bdb0a15fb3d53f6c85b6c9b3 to your computer and use it in GitHub Desktop.
Save MultisampledNight/32fdd881bdb0a15fb3d53f6c85b6c9b3 to your computer and use it in GitHub Desktop.
Typst CI for GH
#!/usr/bin/env sh
cd $(git rev-parse --show-toplevel)
mkdir -p compiled-docs
export TYPST_ROOT="$(pwd)/docs"
for document in $(find -path "./docs/*.typ" -not -path "*/util/*"); do
typst compile $document \
--input "production=true" \
$@
cp "$(dirname $document)/$(basename $document .typ).pdf" compiled-docs/
done
name: Compile docs to PDF
on:
push:
paths:
- ".github/workflows/compile-docs.yaml"
- "**.typ"
pull_request:
paths:
- ".github/workflows/compile-docs.yaml"
- "**.typ"
workflow_dispatch:
permissions:
contents: read
jobs:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache typst
id: cache-typst
uses: actions/cache@v4
with:
path: typst
key: linux-typst-0.11.0
- name: Download typst if uncached
if: steps.cache-typst.outputs.cache-hit != 'true'
# will I remember to update this version? no
run: |
curl -LO https://github.com/typst/typst/releases/download/v0.11.0/typst-x86_64-unknown-linux-musl.tar.xz
du -h typst-x86_64-unknown-linux-musl.tar.xz
tar -xf typst-x86_64-unknown-linux-musl.tar.xz
mv typst-x86_64-unknown-linux-musl/typst ./typst
- name: Cache IBM Plex
id: cache-ibm-plex
uses: actions/cache@v4
with:
path: ibm-plex
key: ibm-plex-6.3.0
- name: Download IBM Plex if uncached
if: steps.cache-ibm-plex.outputs.cache-hit != 'true'
run: |
curl -LO https://github.com/IBM/plex/releases/download/v6.3.0/TrueType.zip
du -h TrueType.zip
unzip TrueType.zip
mv TrueType ibm-plex
- name: Checkout fletcher 0.4.4 with enclose support
uses: actions/checkout@v4
with:
repository: Jollywatt/typst-fletcher
path: fletcher
- name: Move cetz 0.2.0 to where typst can find it
run: |
target="$HOME/.local/share/typst/packages/local/fletcher/0.4.4"
mkdir -p $(dirname $target)
mv fletcher $target
- name: Compile all typst documents
run: |
export PATH="$PATH:$(pwd)"
bash ./docs/compile-all.sh \
--font-path ibm-plex/IBM-Plex-Mono \
--font-path ibm-plex/IBM-Plex-Sans \
- uses: actions/upload-artifact@v4
with:
name: compiled-docs
path: compiled-docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment