Skip to content

Commit 1c5d44a

Browse files
authored
Add protobuf zip generation for releases (opensearch-project#139)
* Add protobuf zip generation for releases Signed-off-by: Karen Xu <karenxyr@gmail.com>
1 parent 17a71a4 commit 1c5d44a

5 files changed

Lines changed: 87 additions & 4 deletions

File tree

.github/workflows/release-drafter.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ name: Release drafter
22

33
# Push events to every tag not containing "/"
44
#
5-
# Publish the commons JAR to Maven Local, and create 'artifacts.tar.gz'
6-
# using build dir and adding the contents of repository
5+
# Publish the Java JAR to Maven Local, and create release artifacts:
6+
# - opensearch-protobufs-java.tar.gz (Java/Maven artifacts)
7+
# - opensearch-protobufs-{version}.zip (Raw proto files)
78
#
89
on:
910
push:
@@ -39,11 +40,17 @@ jobs:
3940
- name: Build with Gradle
4041
run: |
4142
./tools/java/package_proto_jar.sh -c true -s false
42-
./gradlew --no-daemon -Dbuild.snapshot=false publishCreatePublicationToLocalRepoRepository && tar -C build -cvf artifacts.tar.gz repository
43+
./gradlew --no-daemon -Dbuild.snapshot=false publishCreatePublicationToLocalRepoRepository
44+
tar -C build -cvf "opensearch-protobufs-java.tar.gz" repository
45+
46+
- name: Create protobuf zip
47+
run: ./tools/package_proto_zip.sh
48+
4349
- name: Draft a release
4450
uses: softprops/action-gh-release@v1
4551
with:
4652
draft: true
4753
generate_release_notes: true
4854
files: |
49-
artifacts.tar.gz
55+
opensearch-protobufs-java.tar.gz
56+
opensearch-protobufs-*.zip

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
## [Unreleased]
66
### Added
77
- Add Go protobuf generation support ([#131](https://github.com/opensearch-project/opensearch-protobufs/pull/131))
8+
- Add protobuf zip generation for releases ([#139](https://github.com/opensearch-project/opensearch-protobufs/pull/139))
89

910
### Removed
1011

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ docker build --target package-bazel-go .
4545
docker build --target test-bazel-go .
4646
```
4747

48+
## Releases
49+
50+
Each OpenSearch Protobufs release includes:
51+
52+
- **Java Archive**: `opensearch-protobufs-java.tar.gz` - Maven-compatible JAR files for Java/Gradle projects
53+
- **Protobuf ZIP**: `opensearch-protobufs-{version}.zip` - Raw `.proto` files for generating client libraries in any language
54+
55+
Download the latest release from the [GitHub Releases page](https://github.com/opensearch-project/opensearch-protobufs/releases).
56+
57+
### Using Raw Proto Files
58+
59+
1. Download `opensearch-protobufs-{version}.zip` from releases to get just the `.proto` files:
60+
61+
2. Extract the zip:
62+
```bash
63+
unzip opensearch-protobufs-{version}.zip
64+
cd opensearch-protobufs-{version}
65+
```
66+
3. Follow latest documentation on https://protobuf.dev/reference/ to generate client libraries for different languages.
67+
4868
## Generated Code Usage
4969

5070
### Go

jenkins/release.jenkinsFile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ standardReleasePipelineWithGenericTrigger(
88
tokenIdCredential: 'jenkins-opensearch-protobufs-generic-webhook-token',
99
causeString: 'A tag was cut on opensearch-project/opensearch-protobufs repository causing this workflow to run',
1010
downloadReleaseAsset: true,
11+
downloadReleaseAssetName: 'opensearch-protobufs-java.tar.gz',
1112
publishRelease: true) {
1213
publishToMaven(
1314
signingArtifactsPath: "$WORKSPACE/repository/",

tools/package_proto_zip.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

Comments
 (0)