Skip to content

Commit f9d8451

Browse files
committed
publish.yml & generate_proto.sh upgrade
Signed-off-by: nadine.loepfe <[email protected]>
1 parent b4c7a70 commit f9d8451

File tree

2 files changed

+37
-45
lines changed

2 files changed

+37
-45
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ jobs:
1616
with:
1717
python-version: "3.9"
1818

19-
- name: Upgrade pip
20-
run: pip install --upgrade pip
19+
- name: Install build & pdm-backend & grpcio-tools
20+
run: pip install --upgrade pip build pdm-backend grpcio-tools
2121

22-
- name: Install build & pdm-backend
23-
run: pip install build pdm-backend
24-
25-
- name: Generate Protobuf (if needed)
22+
- name: Generate Protobuf
2623
run: bash ./generate_proto.sh
2724

2825
- name: Build wheel and sdist
@@ -32,4 +29,4 @@ jobs:
3229
uses: pypa/gh-action-pypi-publish@release/v1
3330
with:
3431
user: __token__
35-
password: ${{ secrets.PYPI_API_TOKEN }}
32+
password: ${{ secrets.PYPI_API_TOKEN }}

generate_proto.sh

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,79 @@
11
#!/bin/bash
2-
3-
# Source the activate script to set up the PATH for this shell session
4-
source ./.venv/bin/activate
2+
set -e
53

64
hapi_version="v0.57.3"
75
protos_dir=".protos"
86
services_dir="src/hiero_sdk_python/hapi/services"
97
mirror_dir="src/hiero_sdk_python/hapi/mirror"
108

11-
# Step 1: Prepare directories
129
echo "Setting up directories..."
13-
mkdir -p $protos_dir
14-
rm -rf $protos_dir/*
15-
rm -rf $services_dir/*
16-
rm -rf $mirror_dir/*
17-
mkdir -p $services_dir/auxiliary/tss
18-
mkdir -p $services_dir/event
19-
mkdir -p $mirror_dir
20-
touch $services_dir/__init__.py
21-
touch $mirror_dir/__init__.py
10+
mkdir -p "$protos_dir"
11+
rm -rf "$protos_dir"/*
12+
rm -rf "$services_dir"/*
13+
rm -rf "$mirror_dir"/*
14+
mkdir -p "$services_dir/auxiliary/tss"
15+
mkdir -p "$services_dir/event"
16+
mkdir -p "$mirror_dir"
17+
touch "$services_dir/__init__.py"
18+
touch "$mirror_dir/__init__.py"
2219

23-
# Step 2: Download and extract protobuf files
2420
echo "Downloading Hedera protobufs version $hapi_version..."
25-
curl -sL "https://github.com/hashgraph/hedera-protobufs/archive/refs/tags/${hapi_version}.tar.gz" | tar -xz -C $protos_dir --strip-components=1
26-
# Keep 'platform', 'services', and 'mirror', remove everything else
27-
find "$protos_dir" -mindepth 1 -maxdepth 1 ! -name platform ! -name services ! -name mirror -exec rm -r {} +
21+
curl -sL "https://github.com/hashgraph/hedera-protobufs/archive/refs/tags/${hapi_version}.tar.gz" \
22+
| tar -xz -C "$protos_dir" --strip-components=1
23+
24+
find "$protos_dir" -mindepth 1 -maxdepth 1 \
25+
! -name platform ! -name services ! -name mirror -exec rm -r {} +
2826

29-
# Step 3: Compile service and platform protobuf files
3027
echo "Compiling service and platform protobuf files..."
3128
python -m grpc_tools.protoc \
32-
--proto_path=$protos_dir/platform \
33-
--proto_path=$protos_dir/services \
34-
--pyi_out=./$services_dir \
35-
--python_out=./$services_dir \
36-
--grpc_python_out=./$services_dir \
37-
$protos_dir/services/*.proto $protos_dir/services/auxiliary/tss/*.proto $protos_dir/platform/event/*.proto
29+
--proto_path="$protos_dir/platform" \
30+
--proto_path="$protos_dir/services" \
31+
--pyi_out="./$services_dir" \
32+
--python_out="./$services_dir" \
33+
--grpc_python_out="./$services_dir" \
34+
"$protos_dir/services/"*.proto \
35+
"$protos_dir/services/auxiliary/tss/"*.proto \
36+
"$protos_dir/platform/event/"*.proto
3837

39-
# Step 4: Adjust imports for service and platform protobuf files
4038
echo "Adjusting imports for service and platform protobuf files..."
4139
if [[ "$OSTYPE" == "darwin"* ]]; then
42-
find $services_dir -type f -name "*.py" -exec sed -i '' \
40+
find "$services_dir" -type f -name "*.py" -exec sed -i '' \
4341
-e '/^import .*_pb2 as .*__pb2/s/^/from . /' \
4442
-e 's/^from auxiliary\.tss/from .auxiliary.tss/' \
4543
-e 's/^from event/from .event/' {} +
4644
else
47-
find $services_dir -type f -name "*.py" -exec sed -i \
45+
find "$services_dir" -type f -name "*.py" -exec sed -i \
4846
-e '/^import .*_pb2 as .*__pb2/s/^/from . /' \
4947
-e 's/^from auxiliary\.tss/from .auxiliary.tss/' \
5048
-e 's/^from event/from .event/' {} +
5149
fi
5250

53-
# Step 5: Compile mirror protobuf files
5451
echo "Compiling mirror protobuf files..."
5552
python -m grpc_tools.protoc \
56-
--proto_path=$protos_dir/mirror \
57-
--proto_path=$protos_dir/services \
58-
--python_out=$mirror_dir \
59-
--grpc_python_out=$mirror_dir \
60-
$protos_dir/mirror/*.proto
53+
--proto_path="$protos_dir/mirror" \
54+
--proto_path="$protos_dir/services" \
55+
--python_out="$mirror_dir" \
56+
--grpc_python_out="$mirror_dir" \
57+
"$protos_dir/mirror/"*.proto
6158

62-
# Step 6: Adjust imports for mirror protobuf files
6359
echo "Adjusting imports for mirror protobuf files..."
6460
if [[ "$OSTYPE" == "darwin"* ]]; then
65-
find $mirror_dir -type f -name "*.py" -exec sed -i '' \
61+
find "$mirror_dir" -type f -name "*.py" -exec sed -i '' \
6662
-e 's/^import basic_types_pb2 as/import hiero_sdk_python.hapi.services.basic_types_pb2 as/' \
6763
-e 's/^import timestamp_pb2 as/import hiero_sdk_python.hapi.services.timestamp_pb2 as/' \
6864
-e 's/^import consensus_submit_message_pb2 as/import hiero_sdk_python.hapi.services.consensus_submit_message_pb2 as/' \
6965
-e 's/^import consensus_service_pb2 as/import hiero_sdk_python.hapi.mirror.consensus_service_pb2 as/' \
7066
-e 's/^import mirror_network_service_pb2 as/import hiero_sdk_python.hapi.mirror.mirror_network_service_pb2 as/' {} +
7167
else
72-
find $mirror_dir -type f -name "*.py" -exec sed -i \
68+
find "$mirror_dir" -type f -name "*.py" -exec sed -i \
7369
-e 's/^import basic_types_pb2 as/import hiero_sdk_python.hapi.services.basic_types_pb2 as/' \
7470
-e 's/^import timestamp_pb2 as/import hiero_sdk_python.hapi.services.timestamp_pb2 as/' \
7571
-e 's/^import consensus_submit_message_pb2 as/import hiero_sdk_python.hapi.services.consensus_submit_message_pb2 as/' \
7672
-e 's/^import consensus_service_pb2 as/import hiero_sdk_python.hapi.mirror.consensus_service_pb2 as/' \
7773
-e 's/^import mirror_network_service_pb2 as/import hiero_sdk_python.hapi.mirror.mirror_network_service_pb2 as/' {} +
7874
fi
7975

80-
# Step 7: Confirm success
81-
if [ "$(ls -A $services_dir)" ] && [ "$(ls -A $mirror_dir)" ]; then
76+
if [ "$(ls -A "$services_dir")" ] && [ "$(ls -A "$mirror_dir")" ]; then
8277
echo "All protobuf files have been generated and adjusted successfully!"
8378
else
8479
echo "Error: Protobuf file generation or adjustment failed."

0 commit comments

Comments
 (0)