lvignoli / typst-action

Typst GitHub action
MIT License
53 stars 10 forks source link

Typst GitHub action

Build Typst documents using GitHub workflows.

Minimal example

The following .github/workflows/build.yaml action compiles main.typ to main.pdf on every push.

name: Build Typst document
on: push

jobs:
  build_typst_documents:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Typst
        uses: lvignoli/typst-action@main
        with:
          source_file: main.typ

Longer example

Here we compile multiple files on each push, and publish all the PDFs in a tagged and timestamped release when the commit is tagged.

name: Build Typst document
on: [push, workflow_dispatch]

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Typst
        uses: lvignoli/typst-action@main
        with:
          source_file: |
            first_file.typ
            second_file.typ
            third_and_final_file.typ

      - name: Upload PDF file
        uses: actions/upload-artifact@v3
        with:
          name: PDF
          path: *.pdf

      - name: Get current date
        id: date
        run: echo "DATE=$(date +%Y-%m-%d-%H:%M)" >> $GITHUB_ENV

      - name: Release
        uses: softprops/action-gh-release@v1
        if: github.ref_type == 'tag'
        with:
          name: "${{ github.ref_name }} — ${{ env.DATE }}"
          files: main.pdf

Repository lvignoli/typst-action-example provides an example setup on a whole repo.

Notes