Skip to content

Commit c3db374

Browse files
build: add scripts to repack the prebuilt ruby version (#1200)
* build: add bash scripts to prebuild * Update prebuild.sh --------- Co-authored-by: Viacheslav Rostovtsev <[email protected]>
1 parent 8b62a00 commit c3db374

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
env
19+
pwd
20+
bazel --version
21+
22+
mkdir -p output
23+
OUTPUT_DIR=$(realpath output)
24+
25+
bazel build //rules_ruby_gapic/ruby:ruby_context
26+
27+
RUBY_DIRECTORY=$(ls -d "${HOME}"/.cache/bazel/*/*/external/ruby_runtime)
28+
RUBY_VERSION=$(echo 'puts RUBY_VERSION' | "${RUBY_DIRECTORY}/bin/ruby")
29+
echo "Ruby version: $RUBY_VERSION, packing..."
30+
RUBY_ARCHIVE_DIR="ruby-$RUBY_VERSION"
31+
RUBY_TARBALL_FILENAME="ruby-${RUBY_VERSION}_glinux_x86_64.tar.gz"
32+
mkdir -p "$RUBY_ARCHIVE_DIR"
33+
cp -r "$RUBY_DIRECTORY"/bin "$RUBY_DIRECTORY"/include "$RUBY_DIRECTORY"/lib "$RUBY_ARCHIVE_DIR"
34+
tar cfz "${OUTPUT_DIR}/${RUBY_TARBALL_FILENAME}" "$RUBY_ARCHIVE_DIR"
35+
echo "Done: $RUBY_TARBALL_FILENAME"
36+
ls -alh "${OUTPUT_DIR}/${RUBY_TARBALL_FILENAME}"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
if [[ -z "${GOOGLEAPIS_IMAGE}" ]]
19+
then
20+
echo "GOOGLEAPIS_IMAGE not set, defaulting to gcr.io/gapic-images/googleapis:prod"
21+
GOOGLEAPIS_IMAGE="gcr.io/gapic-images/googleapis:prod"
22+
fi
23+
24+
branch="update-binary-`date +%Y%m%dT%H%M%S`"
25+
sourceRoot=$(git rev-parse --show-toplevel)
26+
echo "sourceRoot: ${sourceRoot}"
27+
28+
docker run --rm \
29+
--volume "${sourceRoot}":/workspace \
30+
--workdir "/workspace" \
31+
--entrypoint "/workspace/rules_ruby_gapic/prebuilt/prebuild.sh" \
32+
"${GOOGLEAPIS_IMAGE}"
33+
34+
git checkout -b "${branch}"
35+
rm -rf rules_ruby_gapic/prebuilt/ruby-*.tar.gz
36+
cp output/ruby-*.tar.gz rules_ruby_gapic/prebuilt
37+
git add rules_ruby_gapic/prebuilt/
38+
git commit -m "fix: update Ruby prebuilt binary"
39+
echo "Pushing Ruby branch to GitHub..."
40+
git push --set-upstream origin "${branch}"
41+
42+
echo "Please create pull requests:"
43+
echo " https://github.com/googleapis/gapic-generator-ruby/pull/new/${branch}"

0 commit comments

Comments
 (0)