Skip to content

Commit ac358f4

Browse files
committed
Support precompiled rust gems out of the box
1 parent f7c037e commit ac358f4

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed

Manifest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt
228228
bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
229229
bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt
230230
bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
231+
bundler/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt
231232
bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt
232233
bundler/lib/bundler/templates/newgem/gitignore.tt
233234
bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt

bundler/lib/bundler/cli/gem.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ def run
136136
case config[:ci]
137137
when "github"
138138
templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
139+
if extension == "rust"
140+
templates.merge!("github/workflows/build-gems.yml.tt" => ".github/workflows/build-gems.yml")
141+
end
139142
config[:ci_config_path] = ".github "
140143
when "gitlab"
141144
templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
@@ -447,12 +450,5 @@ def rubocop_version
447450
def standard_version
448451
"1.3"
449452
end
450-
451-
def validate_rust_builder_rubygems_version
452-
if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version
453-
Bundler.ui.error "Your RubyGems version (#{Gem.rubygems_version}) is too old to build Rust extension. Please update your RubyGems using `gem update --system` or any other way and try again."
454-
exit 1
455-
end
456-
end
457453
end
458454
end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: Build gems
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
- "cross-gem/*"
9+
workflow_dispatch:
10+
11+
jobs:
12+
ci-data:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
result: ${{ steps.fetch.outputs.result }}
16+
steps:
17+
- uses: oxidize-rb/actions/fetch-ci-data@v1
18+
id: fetch
19+
with:
20+
supported-ruby-platforms: |
21+
exclude: ["arm-linux", "x64-mingw32"]
22+
stable-ruby-versions: |
23+
exclude: ["2.5", "2.6", "2.7", "head"]
24+
25+
source-gem:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: ruby/setup-ruby@v1
31+
with:
32+
bundler-cache: true
33+
34+
- name: Build gem
35+
run: bundle exec rake build
36+
37+
- uses: actions/upload-artifact@v3
38+
with:
39+
name: source-gem
40+
path: pkg/*.gem
41+
42+
cross-gem:
43+
name: Compile native gem for ${{ matrix.platform }}
44+
runs-on: ubuntu-latest
45+
needs: ci-data
46+
strategy:
47+
matrix:
48+
platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: ruby/setup-ruby@v1
53+
with:
54+
bundler-cache: true
55+
56+
- uses: oxidize-rb/actions/cross-gem@v1
57+
id: cross-gem
58+
with:
59+
platform: ${{ matrix.platform }}
60+
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
61+
62+
- uses: actions/upload-artifact@v3
63+
with:
64+
name: cross-gem
65+
path: ${{ steps.cross-gem.outputs.gem-path }}

0 commit comments

Comments
 (0)