Skip to content

Commit cde31d9

Browse files
authored
Update version to not mark gem as prerelease and add source gem (#173)
1 parent f49e5a3 commit cde31d9

File tree

5 files changed

+81
-22
lines changed

5 files changed

+81
-22
lines changed

.github/workflows/build-gems.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "releases/*"
77

88
jobs:
9-
build-gems:
9+
build-platform-gems:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
@@ -30,23 +30,53 @@ jobs:
3030
working-directory: ./temporalio
3131
cache-version: v1-${{ matrix.rubyPlatform }}
3232

33-
- name: Cross compile gems
33+
- name: Cross compile gem
3434
uses: oxidize-rb/actions/cross-gem@v1
3535
id: cross-gem
3636
with:
3737
platform: ${{ matrix.rubyPlatform }}
3838
ruby-versions: "3.1,3.2,3.3"
3939
working-directory: ./temporalio
4040

41-
- name: Upload gems
41+
- name: Upload gem
4242
uses: actions/upload-artifact@v4
4343
with:
4444
name: ${{ matrix.rubyPlatform }}-gem
4545
path: ${{ steps.cross-gem.outputs.gem-path }}
4646

47+
build-source-gem:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
with:
53+
submodules: recursive
54+
55+
- name: Setup Ruby and Rust
56+
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
57+
with:
58+
ruby-version: "3.3"
59+
bundler-cache: true
60+
cargo-cache: true
61+
cache-version: v1-source
62+
63+
- name: Install bundle
64+
working-directory: ./temporalio
65+
run: bundle install
66+
67+
- name: Build
68+
working-directory: ./temporalio
69+
run: bundle exec rake build
70+
71+
- name: Upload gem
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: source-gem
75+
path: temporalio/pkg/*.gem
76+
4777
smoke-test-gems:
4878
needs:
49-
- build-gems
79+
- build-platform-gems
5080
strategy:
5181
fail-fast: false
5282
matrix:

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
![Ruby 3.1 | 3.2 | 3.3](https://img.shields.io/badge/ruby-3.1%20%7C%203.2%20%7C%203.3-blue.svg?style=for-the-badge)
44
[![MIT](https://img.shields.io/github/license/temporalio/sdk-ruby.svg?style=for-the-badge)](LICENSE)
5-
<!-- TODO: [![Gem](https://img.shields.io/gem/v/temporalio?style=for-the-badge)](https://rubygems.org/gems/temporalio) -->
5+
[![Gem](https://img.shields.io/gem/v/temporalio?style=for-the-badge)](https://rubygems.org/gems/temporalio)
66

77
[Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available orchestration engine used to
88
execute asynchronous, long-running business logic in a scalable and resilient way.
99

1010
**Temporal Ruby SDK** is the framework for authoring workflows and activities using the Ruby programming language.
1111

12+
Also see:
13+
14+
* [Ruby Samples](https://github.com/temporalio/samples-ruby)
15+
* [API Documentation](https://rubydoc.info/gems/temporalio/0.2.0)
16+
1217
⚠️ UNDER ACTIVE DEVELOPMENT
1318

1419
This SDK is under active development and has not released a stable version yet. APIs may change in incompatible ways
@@ -49,6 +54,7 @@ Notably missing from this SDK:
4954
- [Platform Support](#platform-support)
5055
- [Development](#development)
5156
- [Build](#build)
57+
- [Build Platform-specific Gem](#build-platform-specific-gem)
5258
- [Testing](#testing)
5359
- [Code Formatting and Type Checking](#code-formatting-and-type-checking)
5460
- [Proto Generation](#proto-generation)
@@ -59,26 +65,26 @@ Notably missing from this SDK:
5965

6066
### Installation
6167

62-
Install the gem to the desired version as mentioned at https://rubygems.org/gems/temporalio. Since the SDK is still in
63-
pre-release, the version should be specified explicitly. So either in a Gemfile like:
68+
Can require in a Gemfile like:
6469

6570
```
66-
gem 'temporalio', '<version>'
71+
gem 'temporalio'
6772
```
6873

6974
Or via `gem install` like:
7075

7176
```
72-
gem install temporalio -v '<version>'
77+
gem install temporalio
7378
```
7479

80+
**NOTE**: Only macOS ARM/x64 and Linux ARM/x64 are supported, and the platform-specific gem chosen is based on when the
81+
gem/bundle install is performed. A source gem is published but cannot be used directly and will fail to build if tried.
82+
MinGW-based Windows and Linux MUSL do not have gems. See the [Platform Support](#platform-support) section for more
83+
information.
84+
7585
**NOTE**: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
7686
supported on Ruby versions 3.3 and newer.
7787

78-
**NOTE**: MinGW-based Windows is not currently supported natively, but is via WSL. Prebuilt gems for Linux MUSL are also
79-
not currently present. We also do not publish a gem for building from source at this time. See the
80-
[Platform Support](#platform-support) section later for more information.
81-
8288
### Implementing an Activity
8389

8490
Implementing workflows is not yet supported in the Ruby SDK, but implementing activities is.
@@ -462,9 +468,9 @@ This means Linux and macOS for ARM and x64 have published gems. Currently, a gem
462468
Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/172) with Windows and multi-threaded Rust, MinGW-based
463469
Windows (i.e. `x64-mingw-ucrt`) is not supported. But WSL is supported using the normal Linux gem.
464470

465-
At this time a pure source gem is not published, which means that when trying to install the gem on an unsupported
466-
platform, you may get an error that it is not available. Building from source requires many files across submodules and
467-
requires Rust to be installed. See the [Build](#build) section for how to build a gem from the repository.
471+
At this time a pure source gem is published for documentation reasons, but it cannot be built and will fail if tried.
472+
Building from source requires many files across submodules and requires Rust to be installed. See the [Build](#build)
473+
section for how to build a the repository.
468474

469475
The SDK works on Ruby 3.1+, but due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and
470476
`async` gem) are only supported on Ruby versions 3.3 and newer.
@@ -488,13 +494,32 @@ To build shared library for development use:
488494

489495
bundle exec rake compile
490496

491-
Note, this is not `compile:dev` because debug-mode in Rust has
497+
**NOTE**: This will make the current directory usable for the current Ruby version by putting the shared library
498+
`lib/temporalio/internal/bridge/temporalio_bridge.<ext>` in the proper place. But this development shared library may
499+
not work for other Ruby versions or other OS/arch combinations. For that, see "Build Platform-specific Gem" below.
500+
501+
**NOTE**: This is not `compile:dev` because debug-mode in Rust has
492502
[an issue](https://github.com/rust-lang/rust/issues/34283) that causes runtime stack size problems.
493503

494-
To lint, build, and test release:
504+
To lint, build, and test:
495505

496506
bundle exec rake
497507

508+
#### Build Platform-specific Gem
509+
510+
The standard `bundle exec rake build` will produce a gem in the `pkg` directory, but that gem will not be usable because
511+
the shared library is not present (neither the Rust code nor the compiled form). To create a platform-specific gem that
512+
can be used, `rb-sys-dock` must be run. See the
513+
[Cross-Compilation documentation](https://oxidize-rb.github.io/rb-sys/tutorial/publishing/cross-compilation.html) in the
514+
`rb-sys` repository. For example, running:
515+
516+
bundle exec rb-sys-dock --platform x86_64-linux --ruby-versions 3.2,3.3 --build
517+
518+
Will create a `pkg/temporalio-<version>-x86_64-linux.gem` file that can be used in x64 Linux environments on both Ruby
519+
3.2 and Ruby 3.3 because it contains the shared libraries. For this specific example, the shared libraries are inside
520+
the gem at `lib/temporalio/internal/bridge/3.2/temporalio_bridge.so` and
521+
`lib/temporalio/internal/bridge/3.3/temporalio_bridge.so`.
522+
498523
### Testing
499524

500525
This project uses `minitest`. To test:

temporalio/Rakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ task build: :compile
1010

1111
GEMSPEC = Gem::Specification.load('temporalio.gemspec')
1212

13-
RbSys::ExtensionTask.new('temporalio_bridge', GEMSPEC) do |ext|
14-
ext.lib_dir = 'lib/temporalio/internal/bridge'
13+
begin
14+
RbSys::ExtensionTask.new('temporalio_bridge', GEMSPEC) do |ext|
15+
ext.lib_dir = 'lib/temporalio/internal/bridge'
16+
end
17+
rescue RbSys::CargoMetadataError
18+
raise 'Source gem cannot be installed directly, must be a supported platform'
1519
end
1620

1721
require 'rake/testtask'

temporalio/lib/temporalio/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Temporalio
4-
VERSION = '0.2.0-alpha1'
4+
VERSION = '0.2.0'
55
end

temporalio/temporalio.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
1616
spec.metadata['homepage_uri'] = spec.homepage
1717
spec.metadata['source_code_uri'] = 'https://github.com/temporalio/sdk-ruby'
1818

19-
spec.files = Dir['lib/**/*.rb', 'LICENSE', 'README.md', 'Cargo.*']
19+
spec.files = Dir['lib/**/*.rb', 'LICENSE', 'README.md', 'Cargo.*', 'temporalio.gemspec', 'Gemfile', 'Rakefile']
2020

2121
spec.bindir = 'exe'
2222
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }

0 commit comments

Comments
 (0)