11name : Build Tree-sitter Parser
22
33on :
4- schedule :
5- - cron : " 0 0 * * 1" # Weekly on Monday
4+ push :
5+ branches : [main]
6+ paths :
7+ - " tree-sitter-lf/src/**"
8+ - " tree-sitter-lf/grammar.js"
9+ - " tree-sitter-lf/queries/**"
610 workflow_dispatch :
7- inputs :
8- ts_version :
9- description : " tree-sitter-lf release tag (e.g. v0.0.1). Leave empty to auto-detect latest."
10- required : false
11- type : string
1211
1312jobs :
14- check :
15- runs-on : ubuntu-latest
16- outputs :
17- version : ${{ steps.resolve.outputs.version }}
18- should_build : ${{ steps.resolve.outputs.should_build }}
19- steps :
20- - name : Resolve version to build
21- id : resolve
22- env :
23- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
24- run : |
25- if [ -n "${{ inputs.ts_version }}" ]; then
26- version="${{ inputs.ts_version }}"
27- else
28- version=$(gh api repos/remifan/tree-sitter-lf/releases \
29- --jq '[.[] | select(.prerelease == false)][0].tag_name')
30- fi
31-
32- echo "version=$version" >> "$GITHUB_OUTPUT"
33-
34- # Check if this version's parsers already exist by reading ts-version.txt
35- current=$(gh release view artifacts --repo "${{ github.repository }}" --json assets \
36- --jq '.assets[] | select(.name == "ts-version.txt") | .name' 2>/dev/null || true)
37-
38- if [ -n "$current" ]; then
39- # Download and compare
40- gh release download artifacts --repo "${{ github.repository }}" \
41- --pattern "ts-version.txt" --dir /tmp --clobber 2>/dev/null || true
42- existing=$(cat /tmp/ts-version.txt 2>/dev/null || true)
43- if [ "$existing" = "$version" ]; then
44- echo "Tree-sitter $version already built, skipping."
45- echo "should_build=false" >> "$GITHUB_OUTPUT"
46- else
47- echo "Tree-sitter version changed ($existing -> $version), will build."
48- echo "should_build=true" >> "$GITHUB_OUTPUT"
49- fi
50- else
51- echo "No existing tree-sitter build, will build."
52- echo "should_build=true" >> "$GITHUB_OUTPUT"
53- fi
54-
5513 build :
56- needs : check
57- if : needs.check.outputs.should_build == 'true'
5814 strategy :
5915 matrix :
6016 include :
6117 - os : ubuntu-latest
6218 artifact : treesitter-linux-x64.so
63- compile : cc -shared -o treesitter-linux-x64.so -fPIC -O2 -I./src src/parser.c src/scanner.c
19+ compile : cc -shared -o treesitter-linux-x64.so -fPIC -O2 -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
6420 - os : ubuntu-24.04-arm
6521 artifact : treesitter-linux-arm64.so
66- compile : cc -shared -o treesitter-linux-arm64.so -fPIC -O2 -I./src src/parser.c src/scanner.c
22+ compile : cc -shared -o treesitter-linux-arm64.so -fPIC -O2 -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
6723 - os : macos-latest
6824 artifact : treesitter-darwin-x64.so
69- compile : cc -shared -o treesitter-darwin-x64.so -fPIC -O2 -target x86_64-apple-macos11 -I./src src/parser.c src/scanner.c
25+ compile : cc -shared -o treesitter-darwin-x64.so -fPIC -O2 -target x86_64-apple-macos11 -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
7026 - os : macos-latest
7127 artifact : treesitter-darwin-arm64.so
72- compile : cc -shared -o treesitter-darwin-arm64.so -fPIC -O2 -I./src src/parser.c src/scanner.c
28+ compile : cc -shared -o treesitter-darwin-arm64.so -fPIC -O2 -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
7329 - os : windows-latest
7430 artifact : treesitter-win-x64.dll
75- compile : gcc -shared -o treesitter-win-x64.dll -O2 -I./src src/parser.c src/scanner.c
31+ compile : gcc -shared -o treesitter-win-x64.dll -O2 -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
7632 - os : windows-latest
7733 artifact : treesitter-win-arm64.dll
7834 setup : choco install llvm --params "'/InstallAllUsers'" -y
79- compile : clang -shared -o treesitter-win-arm64.dll -O2 --target=aarch64-pc-windows-msvc -I./src src/parser.c src/scanner.c
35+ compile : clang -shared -o treesitter-win-arm64.dll -O2 --target=aarch64-pc-windows-msvc -I./tree-sitter-lf/ src tree-sitter-lf/ src/parser.c tree-sitter-lf/ src/scanner.c
8036 runs-on : ${{ matrix.os }}
8137 steps :
82- - name : Checkout tree-sitter-lf
38+ - name : Checkout
8339 uses : actions/checkout@v4
84- with :
85- repository : remifan/tree-sitter-lf
86- ref : ${{ needs.check.outputs.version }}
8740
8841 - name : Setup toolchain
8942 if : matrix.setup
@@ -99,20 +52,14 @@ jobs:
9952 path : ${{ matrix.artifact }}
10053
10154 release :
102- needs : [check, build]
55+ needs : build
10356 runs-on : ubuntu-latest
10457 steps :
105- - name : Checkout tree-sitter-lf (for queries)
58+ - name : Checkout
10659 uses : actions/checkout@v4
107- with :
108- repository : remifan/tree-sitter-lf
109- ref : ${{ needs.check.outputs.version }}
11060
11161 - name : Package queries
112- run : cd queries && zip -r ../queries.zip .
113-
114- - name : Write version marker
115- run : echo "${{ needs.check.outputs.version }}" > ts-version.txt
62+ run : cd tree-sitter-lf/queries && zip -r ../../queries.zip .
11663
11764 - name : Download all build artifacts
11865 uses : actions/download-artifact@v4
@@ -127,33 +74,27 @@ jobs:
12774 gh release view artifacts --repo "${{ github.repository }}" > /dev/null 2>&1 || \
12875 gh release create artifacts --repo "${{ github.repository }}" \
12976 --title "Pre-built artifacts" \
130- --notes "Pre-built LSP server and tree-sitter parser for lf.nvim.
131-
132- Install in Neovim:
133- \`\`\`vim
134- :LFLspInstall
135- :LFTSInstall
136- \`\`\`"
77+ --notes "Pre-built LSP server and tree-sitter parser for lf.nvim."
13778
13879 - name : Upload to artifacts release
13980 env :
14081 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
14182 run : |
14283 gh release upload artifacts \
143- artifacts/* queries.zip ts-version.txt \
84+ artifacts/* queries.zip \
14485 --repo "${{ github.repository }}" --clobber
14586
14687 - name : Update release title
14788 env :
14889 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
149- TS_VERSION : ${{ needs.check.outputs.version }}
15090 run : |
151- # Read LSP version from existing jar asset name
91+ ts_sha=$(git log -1 --format=%h -- tree-sitter-lf/)
92+
15293 lsp_ver=$(gh release view artifacts --repo "${{ github.repository }}" --json assets \
15394 --jq '[.assets[].name | select(startswith("lsp-"))][0] // ""' \
15495 | sed -n 's/^lsp-\(.*\)-all\.jar$/v\1/p')
15596
156- title="Tree-sitter ${TS_VERSION} "
97+ title="Tree-sitter (${ts_sha}) "
15798 if [ -n "$lsp_ver" ]; then
15899 title="LSP ${lsp_ver} · ${title}"
159100 fi
0 commit comments