Skip to content

📑 Install Typst for use in GitHub Actions

License

Notifications You must be signed in to change notification settings

typst-community/setup-typst

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 简体中文

Setup Typst

This action provides the following functionality for GitHub Actions users:

  • Installing a version of Typst and adding it to the PATH
  • Caching packages dependencies
  • Downloading ZIP archives as local packages
- uses: typst-community/setup-typst@v4
- run: typst compile paper.typ paper.pdf

Usage

Basic usage

name: Render paper.pdf
on: push
jobs:
  render-paper:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: typst-community/setup-typst@v4
      # 🎉 Now Typst is installed!
      - run: typst compile paper.typ paper.pdf

Inputs

Typst version control

  • typst-version: Version range or exact version of Typst to use, using SemVer's version range syntax. Uses the latest version if unset.
  • allow-prereleases: When true, a version range including latest passed to typst-version input will match prerelease versions.
# Example 1
- uses: typst-community/setup-typst@v4
  with:
    typst-version: ^0.13.0

# Example 2
- uses: typst-community/setup-typst@v4
  with:
    typst-version: 0.13.0-rc1
    allow-prereleases: true

Packages cache

cache-dependency-path: Used to specify the path to a Typst file containing lines of import keyword.

# Example workflow YAML file
- uses: typst-community/setup-typst@v4
  with:
   cache-dependency-path: requirements.typ
// Example Typst file (requirements.typ)
#import "@preview/example:0.1.0": *

ZIP archive packages download

  • local-packages: Used to specify the path to a JSON file containing names and ZIP archive URLs of packages as local packages under the local key.
  • cache-local-packages: When true, local packages set by local-packages will be cached independently of @preview packages.
# Example workflow YAML file
- uses: typst-community/setup-typst@v4
  with:
    local-packages: packages.json
    cache-local-packages: true
// Example JSON file (packages.json)
{
  "local": {
    "glossarium": "https://github.com/typst-community/glossarium/archive/refs/tags/v0.5.4.zip",
    "touying": "https://github.com/touying-typ/touying/archive/refs/tags/0.6.1.zip"
  }
}

Note

  • For links to download GitHub repositories, please refer to Downloading source code archives.
  • The namespace for local packages is local. The SemVer versions of local packages are read from its typst.toml.

Token

token: The token used to authenticate when fetching Typst distributions from typst/typst. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.

Outputs

  • typst-version: The installed Typst version. Useful when given a version range as input.
  • cache-hit: A boolean value to indicate a cache entry was found.

Custom combinations

Uploading workflow artifact

If you require storing and sharing data from a workflow, you can use artifacts.

- uses: typst-community/setup-typst@v4
- run: typst compile paper.typ paper.pdf
- uses: actions/upload-artifact@v4
  with:
    name: paper
    path: paper.pdf

Installing fonts with Fontist

If you require installing fonts in GitHub Actions runner, you can use Fontist.

- uses: fontist/setup-fontist@v2
- run: fontist install "Fira Code"
- uses: typst-community/setup-typst@v4
- run: typst compile paper.typ paper.pdf --font-path ~/.fontist/fonts