Skip to content

Commit 64b1a90

Browse files
Automatically update wheel version (opensearch-project#201)
* Add version.bzl and wrap with script to update with version.properties. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Clean up old test comments. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Exclude version.bzl altogether. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Remove wheel check. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Move release workflow to package_proto_wheel.sh. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Add version.bzl back - build fails on fresh run otherwise. Signed-off-by: Finn Carroll <carrofin@amazon.com> * Changelog. Signed-off-by: Finn Carroll <carrofin@amazon.com> * EOF newlines for git. Signed-off-by: Finn Carroll <carrofin@amazon.com> --------- Signed-off-by: Finn Carroll <carrofin@amazon.com>
1 parent bd70b87 commit 64b1a90

6 files changed

Lines changed: 39 additions & 3 deletions

File tree

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Build python with bazel
5353
run: |
5454
mkdir -p dist
55-
bazel build //:opensearch_protos_wheel
55+
./tools/python/package_proto_wheel.sh
5656
mv bazel-bin/opensearch_protobufs-*-py3-none-any.whl dist/
5757
- name: Publish python artifacts to PyPI
5858
uses: pypa/gh-action-pypi-publish@release/v1

BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library")
2+
load("//:version.bzl", "VERSION")
23

34
package(default_visibility = ["//visibility:public"])
45

@@ -137,7 +138,7 @@ py_wheel(
137138
name = "opensearch_protos_wheel",
138139
distribution = "opensearch-protobufs",
139140
python_tag = "py3",
140-
version = "0.12.0",
141+
version = VERSION,
141142
requires = [
142143
"protobuf>=3.20.3",
143144
"grpcio>=1.68.1",

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1515
### Removed
1616

1717
### Fixed
18+
- Update python wheel versioning to read from version.properties ([#201](https://github.com/opensearch-project/opensearch-protobufs/pull/201))
1819

1920
### Security

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ RUN bazel build //:python_protos_all
9494

9595
FROM build-bazel-python AS package-bazel-python
9696

97-
RUN bazel build //:opensearch_protos_wheel
97+
RUN /build/tools/python/package_proto_wheel.sh
9898

9999
FROM package-bazel-python AS test-bazel-python
100100

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Script to package python proto files into a wheel
3+
# This script updates version.bzl from version.properties and then builds the wheel
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
ROOT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
9+
10+
echo "Packaging Python protobuf wheel..."
11+
12+
# Get version from version.properties
13+
VERSION=$(grep '^version=' "${ROOT_DIR}/version.properties" | cut -d'=' -f2)
14+
echo "Found version: ${VERSION}"
15+
16+
# Update version.bzl with the current version
17+
echo "Updating version.bzl..."
18+
cat > "${ROOT_DIR}/version.bzl" << EOF
19+
"""Version information read from version.properties."""
20+
21+
# This file is generated - do not edit manually
22+
VERSION = "${VERSION}"
23+
EOF
24+
25+
echo "Updated version.bzl with version ${VERSION}"
26+
27+
# Build the wheel using Bazel
28+
echo "Building wheel with Bazel..."
29+
cd "${ROOT_DIR}"
30+
bazel build //:opensearch_protos_wheel

version.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Version information read from version.properties."""
2+
3+
# This file is generated - do not edit manually
4+
VERSION = "0.12.0"

0 commit comments

Comments
 (0)