build: package production configs and use system protoc
This commit is contained in:
@@ -5,8 +5,9 @@ set -Eeuo pipefail
|
||||
readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly WORKSPACE_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
|
||||
readonly MODULE_ROOT="${WORKSPACE_ROOT}/module"
|
||||
readonly BUILD_ROOT="${WORKSPACE_ROOT}/builds"
|
||||
readonly BUILD_ROOT="${WORKSPACE_ROOT}/.builds"
|
||||
readonly ENTRY_ROOT="${BUILD_ROOT}/.entries"
|
||||
readonly CONFIG_ROOT="${BUILD_ROOT}/etc"
|
||||
|
||||
if ! command -v go >/dev/null 2>&1; then
|
||||
echo "error: Go is not installed or is not available in PATH" >&2
|
||||
@@ -87,4 +88,18 @@ for module_dir in "${modules[@]}"; do
|
||||
)
|
||||
done
|
||||
|
||||
# Copy production configuration only after every service has compiled successfully.
|
||||
mkdir -p "${CONFIG_ROOT}"
|
||||
config_count=0
|
||||
|
||||
for module_dir in "${modules[@]}"; do
|
||||
module_name="$(basename -- "${module_dir}")"
|
||||
config_name="${module_name}_prod.yaml"
|
||||
config_file="${module_dir}/etc/${config_name}"
|
||||
[[ -f "${config_file}" ]] || continue
|
||||
cp -- "${config_file}" "${CONFIG_ROOT}/${config_name}"
|
||||
((config_count += 1))
|
||||
done
|
||||
|
||||
echo "Copied ${config_count} production configs to ${CONFIG_ROOT}"
|
||||
echo "Build completed successfully: ${BUILD_ROOT}"
|
||||
|
||||
@@ -4,29 +4,10 @@ set -Eeuo pipefail
|
||||
|
||||
readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly WORKSPACE_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
|
||||
readonly TOOL_ROOT="${WORKSPACE_ROOT}/.tools"
|
||||
|
||||
protoc_bin="${TOOL_ROOT}/protoc/bin/protoc"
|
||||
plugin_dir="${TOOL_ROOT}/bin"
|
||||
|
||||
if [[ "${OS:-}" == "Windows_NT" ]]; then
|
||||
protoc_bin="${protoc_bin}.exe"
|
||||
fi
|
||||
|
||||
if [[ ! -x "${protoc_bin}" ]]; then
|
||||
protoc_bin="$(command -v protoc || true)"
|
||||
fi
|
||||
|
||||
if [[ -z "${protoc_bin}" ]]; then
|
||||
echo "error: protoc was not found; install it or place it under .tools/protoc" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PATH="${plugin_dir}:${PATH}"
|
||||
|
||||
for plugin in protoc-gen-go protoc-gen-go-grpc protoc-gen-grpc-gateway; do
|
||||
if ! command -v "${plugin}" >/dev/null 2>&1; then
|
||||
echo "error: ${plugin} was not found in PATH or .tools/bin" >&2
|
||||
for tool in protoc protoc-gen-go protoc-gen-go-grpc protoc-gen-grpc-gateway; do
|
||||
if ! command -v "${tool}" >/dev/null 2>&1; then
|
||||
echo "error: ${tool} was not found in PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -34,7 +15,7 @@ done
|
||||
cd -- "${WORKSPACE_ROOT}"
|
||||
|
||||
echo "==> protobuf/blocks.proto"
|
||||
"${protoc_bin}" \
|
||||
protoc \
|
||||
--proto_path="${WORKSPACE_ROOT}" \
|
||||
--go_out="${WORKSPACE_ROOT}/protobuf" \
|
||||
--go_opt=module=bsm/full/protobuf \
|
||||
@@ -57,7 +38,7 @@ while IFS= read -r -d '' go_mod; do
|
||||
(( ${#proto_files[@]} > 0 )) || continue
|
||||
|
||||
echo "==> ${module_path} (${#proto_files[@]} files)"
|
||||
"${protoc_bin}" \
|
||||
protoc \
|
||||
--proto_path="${WORKSPACE_ROOT}" \
|
||||
--go_out="${module_dir}" \
|
||||
--go_opt="module=${module_path}" \
|
||||
|
||||
Reference in New Issue
Block a user