summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Ker-Seymer <ian.kerseymer@shopify.com>2024-05-30 23:22:16 -0400
committergit <svn-admin@ruby-lang.org>2026-02-13 06:28:13 +0000
commit211c17dcac82fec630bd6e57d362abbf6f281eae (patch)
tree556dbf683cebd31445edbb45c9ba57634e6a6fad
parente785e466daab8c85d8e6cdfb05fa43c488e74db2 (diff)
[ruby/rubygems] Support precompiled rust gems out of the box
https://github.com/ruby/rubygems/commit/5d3fbf0280
-rw-r--r--lib/bundler/cli/gem.rb3
-rw-r--r--lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt65
2 files changed, 68 insertions, 0 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 0ff0f5e11f..79344314fe 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -158,6 +158,9 @@ module Bundler
case config[:ci]
when "github"
templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
+ if extension == "rust"
+ templates.merge!("github/workflows/build-gems.yml.tt" => ".github/workflows/build-gems.yml")
+ end
config[:ignore_paths] << ".github/"
when "gitlab"
templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
diff --git a/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt b/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt
new file mode 100644
index 0000000000..2c387f0c14
--- /dev/null
+++ b/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt
@@ -0,0 +1,65 @@
+---
+name: Build gems
+
+on:
+ push:
+ tags:
+ - "v*"
+ - "cross-gem/*"
+ workflow_dispatch:
+
+jobs:
+ ci-data:
+ runs-on: ubuntu-latest
+ outputs:
+ result: ${{ steps.fetch.outputs.result }}
+ steps:
+ - uses: oxidize-rb/actions/fetch-ci-data@v1
+ id: fetch
+ with:
+ supported-ruby-platforms: |
+ exclude: ["arm-linux", "x64-mingw32"]
+ stable-ruby-versions: |
+ exclude: ["2.5", "2.6", "2.7", "head"]
+
+ source-gem:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Build gem
+ run: bundle exec rake build
+
+ - uses: actions/upload-artifact@v3
+ with:
+ name: source-gem
+ path: pkg/*.gem
+
+ cross-gem:
+ name: Compile native gem for ${{ matrix.platform }}
+ runs-on: ubuntu-latest
+ needs: ci-data
+ strategy:
+ matrix:
+ platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - uses: oxidize-rb/actions/cross-gem@v1
+ id: cross-gem
+ with:
+ platform: ${{ matrix.platform }}
+ ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
+
+ - uses: actions/upload-artifact@v3
+ with:
+ name: cross-gem
+ path: ${{ steps.cross-gem.outputs.gem-path }}