|
| 1 | +#!/bin/bash |
| 2 | +# Script to package proto files into a zip for release |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 7 | +ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" |
| 8 | + |
| 9 | +# Get version from version.properties |
| 10 | +VERSION=$(grep 'version=' "${ROOT_DIR}/version.properties" | cut -d'=' -f2) |
| 11 | +ZIP_NAME="opensearch-protobufs-${VERSION}.zip" |
| 12 | + |
| 13 | +echo "Creating protobuf zip: ${ZIP_NAME}" |
| 14 | + |
| 15 | +# Create temporary directory for organization |
| 16 | +TEMP_DIR=$(mktemp -d) |
| 17 | +PROTO_DIR="${TEMP_DIR}/opensearch-protobufs-${VERSION}" |
| 18 | + |
| 19 | +# Copy proto files with structure |
| 20 | +mkdir -p "${PROTO_DIR}/schemas" |
| 21 | +mkdir -p "${PROTO_DIR}/services" |
| 22 | + |
| 23 | +cp "${ROOT_DIR}/protos/schemas"/*.proto "${PROTO_DIR}/schemas/" |
| 24 | +cp "${ROOT_DIR}/protos/services"/*.proto "${PROTO_DIR}/services/" |
| 25 | + |
| 26 | +# Add a README for the zip |
| 27 | +cat > "${PROTO_DIR}/README.txt" << EOF |
| 28 | +OpenSearch Protocol Buffers v${VERSION} |
| 29 | +
|
| 30 | +This archive contains the Protocol Buffer (.proto) files for OpenSearch gRPC APIs. |
| 31 | +
|
| 32 | +Structure: |
| 33 | +- schemas/ - Core data structure definitions |
| 34 | +- services/ - gRPC service definitions |
| 35 | +
|
| 36 | +Usage: |
| 37 | +Use these .proto files with your preferred Protocol Buffer compiler (protoc) |
| 38 | +to generate client libraries for your programming language. |
| 39 | +
|
| 40 | +For more information, visit: |
| 41 | +https://github.com/opensearch-project/opensearch-protobufs |
| 42 | +
|
| 43 | +EOF |
| 44 | + |
| 45 | +# Create the zip |
| 46 | +cd "${TEMP_DIR}" |
| 47 | +zip -r "${ROOT_DIR}/${ZIP_NAME}" "opensearch-protobufs-${VERSION}/" |
| 48 | + |
| 49 | +# Cleanup |
| 50 | +rm -rf "${TEMP_DIR}" |
| 51 | + |
| 52 | +echo "Successfully created: ${ZIP_NAME}" |
| 53 | +echo "Contents:" |
| 54 | +unzip -l "${ROOT_DIR}/${ZIP_NAME}" |
0 commit comments