forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamcity-diagram-generation.sh
44 lines (31 loc) · 1.33 KB
/
teamcity-diagram-generation.sh
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
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "${0}")/teamcity-support.sh"
source "$(dirname "${0}")/teamcity-bazel-support.sh"
cockroach_ref=$(git describe --tags --exact-match 2>/dev/null || git rev-parse HEAD)
git clone https://github.com/cockroachdb/generated-diagrams.git
# Update diagrams on Github.
export GIT_AUTHOR_NAME="Cockroach TeamCity"
export GIT_COMMITTER_NAME="Cockroach TeamCity"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_COMMITTER_EMAIL="[email protected]"
cd generated-diagrams
git checkout $TC_BUILD_BRANCH || git checkout -b $TC_BUILD_BRANCH
# Clean out old diagrams.
rm -rf bnf && mkdir bnf
rm -rf grammar_svg && mkdir grammar_svg
tc_start_block "Generate Diagrams"
# Must run this from the root.
cd ..
run_bazel build/teamcity/cockroach/publish-sql-grammar-diagrams-impl.sh
cp $root/artifacts/bazel-bin/docs/generated/sql/bnf/*.bnf ./generated-diagrams/bnf
cp $root/artifacts/bazel-bin/docs/generated/sql/bnf/*.html ./generated-diagrams/grammar_svg
tc_end_block "Generate Diagrams"
tc_start_block "Push Diagrams to Git"
cd generated-diagrams
git add .
git commit -m "Snapshot $cockroach_ref"
github_ssh_key="${PRIVATE_DEPLOY_KEY_FOR_GENERATED_DIAGRAMS}"
configure_git_ssh_key
git_wrapped push -f ssh://[email protected]/cockroachdb/generated-diagrams.git
tc_end_block "Push Diagrams to Git"