This is an automated email from the ASF dual-hosted git repository.

erickguan pushed a commit to branch publish-ruby-binding
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 84067af8c9240366f1b6d79dc77df6e3420c0909
Author: Erick Guan <297343+erickg...@users.noreply.github.com>
AuthorDate: Fri Aug 29 23:11:23 2025 +0200

    feat(bindings/ruby): trust publishing Ruby binding
---
 .github/workflows/release_ruby.yml | 64 ++++++++++++++++++++++++++++++++++++++
 bindings/ruby/Cargo.toml           |  1 +
 bindings/ruby/Rakefile             |  5 +++
 bindings/ruby/opendal.gemspec      |  7 +++--
 4 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/release_ruby.yml 
b/.github/workflows/release_ruby.yml
new file mode 100644
index 000000000..d423d0347
--- /dev/null
+++ b/.github/workflows/release_ruby.yml
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Release Ruby Binding
+
+on:
+  workflow_dispatch: # allow repo collaborators to publish gem
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
+  cancel-in-progress: true
+
+permissions:
+  contents: read # use write if we want `rake release` to push the release tag
+  id-token: write # required for workflow to publish gem
+
+jobs:
+  release:
+    if: github.ref == 'refs/heads/master'
+    runs-on: ubuntu-latest
+
+    defaults:
+      run:
+        working-directory: bindings/ruby
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+        with:
+          persist-credentials: false
+
+      # required to run `rake release`.
+      - name: Setup Ruby and install dependencies
+        uses: ruby/setup-ruby@v1
+        with:
+          # setup-ruby implicitly uses .tool-versions
+          bundler-cache: true
+          working-directory: bindings/ruby # we must set it again because 
actions don't use the workflow's job defaults
+
+      # Run `rake release` to create git tag and push to repository.
+      # Then publish the new gem via trusted publishing
+      # Read more on 
https://guides.rubygems.org/trusted-publishing/releasing-gems/
+      - name: Publish gem
+        uses: rubygems/release-gem@v1
+
+      - name: Log Release
+        run: |
+          echo "## Ruby binding released! :rocket:" >> "$GITHUB_STEP_SUMMARY"
+          echo "" >> "$GITHUB_STEP_SUMMARY" # this is a blank line
+          echo "Version: $(bundle exec rake version)" >> "$GITHUB_STEP_SUMMARY"
diff --git a/bindings/ruby/Cargo.toml b/bindings/ruby/Cargo.toml
index e211afdc9..ab52fe72c 100644
--- a/bindings/ruby/Cargo.toml
+++ b/bindings/ruby/Cargo.toml
@@ -25,6 +25,7 @@ homepage = "https://opendal.apache.org/";
 license = "Apache-2.0"
 repository = "https://github.com/apache/opendal";
 rust-version = "1.82"
+version = "0.1.0"
 
 [lib]
 crate-type = ["cdylib"]
diff --git a/bindings/ruby/Rakefile b/bindings/ruby/Rakefile
index 90c0977a3..a54b31ea9 100644
--- a/bindings/ruby/Rakefile
+++ b/bindings/ruby/Rakefile
@@ -71,3 +71,8 @@ end
 
 task doc: "doc:default"
 task default: %i[clobber compile test standard]
+
+desc 'report gem version'
+task :version do
+  print GEMSPEC.version
+end
diff --git a/bindings/ruby/opendal.gemspec b/bindings/ruby/opendal.gemspec
index 81a6361a8..90c306ecd 100644
--- a/bindings/ruby/opendal.gemspec
+++ b/bindings/ruby/opendal.gemspec
@@ -39,20 +39,21 @@ Gem::Specification.new do |spec|
 
   spec.summary = "OpenDAL Ruby Binding"
   spec.homepage = "https://opendal.apache.org/";
-
-  spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 
'https://example.com'"
+  spec.license = 'Apache-2.0'
 
   spec.metadata["homepage_uri"] = spec.homepage
   spec.metadata["source_code_uri"] = "https://github.com/apache/opendal";
   spec.metadata["changelog_uri"] = "https://github.com/apache/opendal/releases";
+  spec.metadata["rubygems_mfa_required"] = "true"
 
   # Specify which files should be added to the gem when it is released.
   # The `git ls-files -z` loads the files in the RubyGem that have been added 
into git.
   spec.files = Dir.chdir(__dir__) do
     `git ls-files -z`.split("\x0").reject do |f|
-      (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ 
features/ .git .circleci appveyor])
+      (File.expand_path(f) == __FILE__) || f.start_with?(*%w[gems/ pkg/ 
target/ tmp/ .git])
     end
   end
+
   spec.bindir = "exe"
   spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
   spec.require_paths = ["lib"]

Reply via email to