@@ -18,13 +18,29 @@ jobs:
1818 matrix :
1919 # TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
2020 # https://github.com/temporalio/sdk-ruby/issues/172
21- rubyPlatform : ["aarch64-linux", "aarch64-linux-musl", "x86_64-linux", "x86_64-linux-musl", "arm64-darwin", "x86_64-darwin"]
21+ include :
22+ - rubyPlatform : aarch64-linux
23+ dockerPlatform : linux/arm64/v8
24+ - rubyPlatform : aarch64-linux-musl
25+ dockerPlatform : linux/arm64/v8
26+ - rubyPlatform : x86_64-linux
27+ dockerPlatform : linux/amd64
28+ - rubyPlatform : x86_64-linux-musl
29+ dockerPlatform : linux/amd64
30+ - rubyPlatform : arm64-darwin
31+ dockerPlatform : linux/arm64/v8
32+ - rubyPlatform : x86_64-darwin
33+ dockerPlatform : linux/amd64
2234 steps :
2335 - name : Checkout repository
2436 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2537 with :
2638 submodules : recursive
2739
40+ - name : Read protoc version
41+ shell : bash
42+ run : echo "PROTOC_VERSION=$(tr -d '\n' < .protoc-version)" >> "$GITHUB_ENV"
43+
2844 - name : Setup Ruby and Rust
2945 uses : oxidize-rb/actions/setup-ruby-and-rust@e5f9a49a7812a078584072f6e3f657ad247c8771 # v1
3046 with :
@@ -35,19 +51,23 @@ jobs:
3551 working-directory : ./temporalio
3652 cache-version : v1-${{ matrix.rubyPlatform }}
3753
38- - name : Install protoc
39- uses : arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3
40- with :
41- version : " 34.x"
42- repo-token : ${{ secrets.GITHUB_TOKEN }}
43-
44- - name : Export protoc paths
45- shell : bash
54+ # rb-sys-dock runs the native gem build inside a Docker container and does
55+ # not inherit arbitrary host tools, so we derive a pinned image with the
56+ # exact protoc version baked in for release builds.
57+ - name : Build rb-sys-dock image
58+ id : build-rb-sys-dock-image
59+ working-directory : ./temporalio
4660 run : |
47- protoc_bin="$(command -v protoc)"
48- protoc_root="$(cd "$(dirname "$protoc_bin")/.." && pwd)"
49- echo "PROTOC=$protoc_bin" >> "$GITHUB_ENV"
50- echo "PROTOC_INCLUDE=$protoc_root/include" >> "$GITHUB_ENV"
61+ rb_sys_version="$(ruby -e 'require \"rb_sys/version\"; puts RbSys::VERSION')"
62+ custom_image="temporalio-rbsys/${{ matrix.rubyPlatform }}:${rb_sys_version}-protoc-${PROTOC_VERSION}"
63+ docker build \
64+ --platform "${{ matrix.dockerPlatform }}" \
65+ --build-arg BASE_IMAGE="rbsys/${{ matrix.rubyPlatform }}:${rb_sys_version}" \
66+ --build-arg PROTOC_VERSION="${PROTOC_VERSION}" \
67+ -t "$custom_image" \
68+ -f ../.github/docker/rb-sys-protoc.Dockerfile \
69+ ..
70+ echo "image=$custom_image" >> $GITHUB_OUTPUT
5171
5272 # Cannot use oxidize-rb/actions/cross-gem because it has older Rust and we
5373 # need --mount-toolchains to get latest Rust, see
5777 working-directory : ./temporalio
5878 run : |
5979 gem install rb_sys --no-document
60- rb-sys-dock --platform ${{ matrix.rubyPlatform }} --ruby-versions "3.3,3.4,4.0" --mount-toolchains --build
80+ RCD_IMAGE="${{ steps.build-rb-sys-dock-image.outputs.image }}" rb-sys-dock --platform ${{ matrix.rubyPlatform }} --ruby-versions "3.3,3.4,4.0" --mount-toolchains --build
6181 echo "gem-path=$(find pkg -name '*-${{ matrix.rubyPlatform }}.gem')" >> $GITHUB_OUTPUT
6282
6383 - name : Upload gem
7595 with :
7696 submodules : recursive
7797
98+ - name : Read protoc version
99+ shell : bash
100+ run : echo "PROTOC_VERSION=$(tr -d '\n' < .protoc-version)" >> "$GITHUB_ENV"
101+
78102 - name : Setup Ruby and Rust
79103 uses : oxidize-rb/actions/setup-ruby-and-rust@e5f9a49a7812a078584072f6e3f657ad247c8771 # v1
80104 with :
@@ -86,17 +110,9 @@ jobs:
86110 - name : Install protoc
87111 uses : arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3
88112 with :
89- version : " 34.x "
113+ version : ${{ env.PROTOC_VERSION }}
90114 repo-token : ${{ secrets.GITHUB_TOKEN }}
91115
92- - name : Export protoc paths
93- shell : bash
94- run : |
95- protoc_bin="$(command -v protoc)"
96- protoc_root="$(cd "$(dirname "$protoc_bin")/.." && pwd)"
97- echo "PROTOC=$protoc_bin" >> "$GITHUB_ENV"
98- echo "PROTOC_INCLUDE=$protoc_root/include" >> "$GITHUB_ENV"
99-
100116 - name : Fix gem directory permissions
101117 run : chmod -R o-w "$RUNNER_TOOL_CACHE/Ruby" || true
102118
0 commit comments