Skip to content

Commit 97682cc

Browse files
committed
Add workflow to build tree-sitter parsers
1 parent 7ff1338 commit 97682cc

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build Tree-Sitter Parsers
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'parsers.toml'
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-parsers:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
platform: linux
19+
- os: macos-latest
20+
platform: macos
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
26+
- name: Install Rust toolchain
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: stable
30+
override: true
31+
32+
- name: Install tsdl
33+
run: |
34+
cargo install tsdl
35+
36+
- name: Build tree-sitter parsers
37+
run: |
38+
tsdl build
39+
40+
- name: Rename built parsers to include platform
41+
run: |
42+
for dir in parsers/*; do
43+
if [ -d "$dir/src" ]; then
44+
lib_dir="$dir/src"
45+
cd "$lib_dir"
46+
for file in *; do
47+
if [ -f "$file" ]; then
48+
extension="${file##*.}"
49+
base="${file%.*}"
50+
mv "$file" "${base}-${{ matrix.platform }}.${extension}"
51+
fi
52+
done
53+
cd - > /dev/null
54+
fi
55+
done
56+
57+
- name: Configure git
58+
run: |
59+
git config user.name "${{ github.actor }}"
60+
git config user.email "${{ github.actor }}@users.noreply.github.com"
61+
62+
- name: Check for changes
63+
id: changes
64+
run: |
65+
git add -A
66+
if git diff --cached --quiet; then
67+
echo "changes=false" >> $GITHUB_OUTPUT
68+
else
69+
echo "changes=true" >> $GITHUB_OUTPUT
70+
fi
71+
72+
- name: Pull latest changes
73+
if: steps.changes.outputs.changes == 'true'
74+
run: |
75+
git pull --rebase
76+
77+
- name: Commit changes
78+
if: steps.changes.outputs.changes == 'true'
79+
run: |
80+
git commit -m "Build tree-sitter parsers for ${{ matrix.platform }} [skip ci]"
81+
82+
- name: Push changes
83+
if: steps.changes.outputs.changes == 'true'
84+
run: |
85+
git push

0 commit comments

Comments
 (0)