|
| 1 | +name: Build tree-sitter-typst |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build-linux: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + with: |
| 12 | + repository: uben0/tree-sitter-typst |
| 13 | + - uses: actions/setup-node@v4 |
| 14 | + with: |
| 15 | + node-version: 20 |
| 16 | + - run: npm install -g tree-sitter-cli |
| 17 | + |
| 18 | + - name: Build Linux .so |
| 19 | + run: | |
| 20 | + tree-sitter build --output tree-sitter-typst.so |
| 21 | + - uses: actions/upload-artifact@v4 |
| 22 | + with: |
| 23 | + name: tree-sitter-typst.so |
| 24 | + path: tree-sitter-typst.so |
| 25 | + |
| 26 | + build-wasm: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + repository: uben0/tree-sitter-typst |
| 32 | + - uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: 20 |
| 35 | + - run: npm install -g tree-sitter-cli wasm-pack |
| 36 | + |
| 37 | + - name: Build WebAssembly |
| 38 | + run: | |
| 39 | + tree-sitter build --wasm --output tree-sitter-typst.wasm |
| 40 | + - uses: actions/upload-artifact@v4 |
| 41 | + with: |
| 42 | + name: tree-sitter-typst.wasm |
| 43 | + path: tree-sitter-typst.wasm |
| 44 | + |
| 45 | + build-windows: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + repository: uben0/tree-sitter-typst |
| 51 | + - uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: 20 |
| 54 | + - run: npm install -g tree-sitter-cli |
| 55 | + |
| 56 | + - name: Install MinGW for cross-compilation |
| 57 | + run: | |
| 58 | + sudo apt update |
| 59 | + sudo apt install -y mingw-w64 |
| 60 | +
|
| 61 | + - name: Build Windows .dll |
| 62 | + run: | |
| 63 | + CC=x86_64-w64-mingw32-gcc CFLAGS="-D_WIN32" tree-sitter build --output tree-sitter-typst.dll |
| 64 | + continue-on-error: true |
| 65 | + # At the end of the build process, tree-sitter will complain that |
| 66 | + # “tree-sitter-typst.dll: invalid ELF header”, because it fails to verify dll on Linux. |
| 67 | + # We could ignore this error and manually verify the dll on Windows. |
| 68 | + |
| 69 | + - name: Verify that .dll was created |
| 70 | + run: | |
| 71 | + ls -la tree-sitter-typst.dll |
| 72 | + file tree-sitter-typst.dll |
| 73 | +
|
| 74 | + - uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: tree-sitter-typst.dll |
| 77 | + path: tree-sitter-typst.dll |
0 commit comments