2020-07-31 22:13:06 +07:00
|
|
|
add_bazel() {
|
2020-11-17 10:52:21 +07:00
|
|
|
if ! command -v bazel; then
|
|
|
|
if [ "$(uname -s)" = "Linux" ]; then
|
2020-07-31 22:13:06 +07:00
|
|
|
${apt_install:?} curl gnupg
|
2020-11-11 03:53:45 +07:00
|
|
|
get -s -n "" https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
|
2020-07-31 22:13:06 +07:00
|
|
|
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
|
|
|
|
sudo "${debconf_fix:?}" apt-get update -y
|
|
|
|
${apt_install:?} bazel
|
2020-11-17 10:52:21 +07:00
|
|
|
else
|
2020-07-31 22:13:06 +07:00
|
|
|
brew install bazel
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_grpc_tag() {
|
|
|
|
if [ "$grpc_tag" = "latest" ]; then
|
2020-11-26 22:02:04 +07:00
|
|
|
grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
|
2020-07-31 22:13:06 +07:00
|
|
|
else
|
2020-11-26 22:02:04 +07:00
|
|
|
if [[ ${grpc_tag:0:1} != "v" ]] ; then grpc_tag="v$grpc_tag"; fi
|
|
|
|
status_code=$(get -v -n /tmp/grpc.tmp "https://github.com/grpc/grpc/releases/tag/$grpc_tag")
|
|
|
|
if [ "$status_code" != "200" ]; then
|
|
|
|
grpc_tag=$(get -s -n "" https://github.com/grpc/grpc/releases/latest | grep -Eo -m 1 "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
|
2020-07-31 22:13:06 +07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-07-13 15:04:07 +07:00
|
|
|
add_grpc_php_plugin_brew() {
|
2020-12-02 10:38:28 +07:00
|
|
|
brew install grpc
|
|
|
|
brew link --force --overwrite grpc >/dev/null 2>&1
|
|
|
|
grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
|
|
|
|
license_path="$(brew --prefix grpc)/LICENSE"
|
|
|
|
}
|
|
|
|
|
2021-07-13 15:04:07 +07:00
|
|
|
add_grpc_php_plugin_compile() {
|
2020-12-02 10:38:28 +07:00
|
|
|
get_grpc_tag
|
|
|
|
get -s -n "" "https://github.com/grpc/grpc/archive/$grpc_tag.tar.gz" | tar -xz -C /tmp
|
2021-07-13 15:04:07 +07:00
|
|
|
export DISABLE_BAZEL_WRAPPER=1
|
|
|
|
(
|
|
|
|
cd "/tmp/grpc-${grpc_tag:1}" || exit
|
|
|
|
add_bazel
|
2021-08-03 00:40:43 +07:00
|
|
|
./tools/bazel build src/compiler:grpc_php_plugin
|
2021-07-13 15:04:07 +07:00
|
|
|
sudo mv ./bazel-bin/src/compiler/grpc_php_plugin /usr/local/bin/grpc_php_plugin
|
|
|
|
sudo chmod a+x /usr/local/bin/grpc_php_plugin
|
|
|
|
license_path="/tmp/grpc-${grpc_tag:1}/LICENSE"
|
|
|
|
)
|
2020-12-02 10:38:28 +07:00
|
|
|
}
|
|
|
|
|
2020-07-31 22:13:06 +07:00
|
|
|
add_grpc_php_plugin() {
|
|
|
|
grpc_tag=$1
|
2020-12-02 10:38:28 +07:00
|
|
|
license_path=""
|
2021-07-13 15:04:07 +07:00
|
|
|
if [ "$grpc_tag" = "latest" ]; then
|
|
|
|
add_grpc_php_plugin_brew >/dev/null 2>&1
|
2020-12-02 10:38:28 +07:00
|
|
|
else
|
2021-07-13 15:04:07 +07:00
|
|
|
add_grpc_php_plugin_compile >/dev/null 2>&1
|
2020-12-02 10:38:28 +07:00
|
|
|
fi
|
|
|
|
echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)"
|
2020-09-28 12:28:02 +07:00
|
|
|
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
|
2020-07-31 22:13:06 +07:00
|
|
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
|
2020-12-02 10:38:28 +07:00
|
|
|
cat "$license_path"
|
2020-07-31 22:13:06 +07:00
|
|
|
echo "::endgroup::"
|
|
|
|
}
|