-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathrelease
executable file
·56 lines (50 loc) · 1.25 KB
/
release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/env bash
#
# Place the generated files into their own repo, to be used by an external
# repo as a submodule.
#
set -eu
langs=("$@")
id=$(git rev-parse --short HEAD)
if [[ -n "$(git status --porcelain)" ]]; then
cat 2>&1 <<EOF
git status is not clean.
Please add and commit files until 'git status' shows a clean status,
then retry.
EOF
exit 1
fi
if [[ ! -d ocaml-tree-sitter-lang ]]; then
git clone [email protected]:returntocorp/ocaml-tree-sitter-lang.git
fi
# Stay on whatever branch is checked out.
repo="ocaml-tree-sitter-lang"
# Copy the files that we find.
#
for lang in "${langs[@]}"; do
make -C "$lang" clean
make -C "$lang" gen
if [[ -d "$lang"/ocaml-src ]]; then
dst="$repo"/"$lang"
mkdir -p "$dst"
cp -a "$lang"/ocaml-src/lib "$dst"
cp -a "$lang"/ocaml-src/bin "$dst"
if [[ -d "$lang"/orig ]]; then
mkdir -p "$dst"/orig
fi
if [[ -f "$lang"/orig/grammar.js ]]; then
cp -a "$lang"/orig/grammar.js "$dst"/orig
fi
if [[ -f "$lang"/orig/LICENSE ]]; then
cp -a "$lang"/orig/LICENSE "$dst"/orig
fi
fi
done
(
cd "$repo"
git add .
git status
git commit -m "Release files generated by ocaml-tree-sitter $id."
branch=$(git rev-parse --abbrev-ref HEAD)
git push origin "$branch"
)