Skip to content

Commit 6fc8dc9

Browse files
committed
Fix platform-specific gem builds and add trusted publishing
The RUBY_ENGINE conditional in the gemspec was only evaluated at build time, so the published gem always depended on llhttp regardless of the installer's Ruby engine. Fix by building platform-specific variants (ruby and java) via a matrix strategy that runs on both CRuby and JRuby.
1 parent 6346bd3 commit 6fc8dc9

4 files changed

Lines changed: 52 additions & 5 deletions

File tree

.github/workflows/push.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Push gem to RubyGems
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
push:
13+
if: github.repository == 'httprb/http'
14+
runs-on: ubuntu-latest
15+
16+
environment:
17+
name: rubygems.org
18+
url: https://rubygems.org/gems/http
19+
20+
permissions:
21+
contents: write
22+
id-token: write
23+
24+
strategy:
25+
matrix:
26+
ruby: [ ruby, jruby ]
27+
28+
steps:
29+
- uses: actions/checkout@v6
30+
31+
- uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby }}
34+
bundler-cache: true
35+
36+
- uses: rubygems/release-gem@v1
37+
38+
- name: Create GitHub release
39+
run: |
40+
tag_name="$(git describe --tags --abbrev=0)"
41+
gh release create "${tag_name}" --verify-tag --generate-notes
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
if: matrix.ruby == 'ruby'

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
ruby: [ ruby-3.2, ruby-3.3, ruby-3.4, ruby-4.0 ]
18+
ruby: [ ruby-3.2, ruby-3.3, ruby-3.4, ruby-4.0, jruby-9.4, jruby-10.0, truffleruby ]
1919

2020
steps:
2121
- uses: actions/checkout@v6

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ the following Ruby versions:
193193
- Ruby 3.3
194194
- Ruby 3.4
195195
- Ruby 4.0
196+
- JRuby 9.4
197+
- JRuby 10.0
198+
- TruffleRuby
196199

197200
If something doesn't work on one of these versions, it's a bug.
198201

http.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ Gem::Specification.new do |spec|
4040
spec.add_dependency "http-cookie", "~> 1.0"
4141
spec.add_dependency "http-form_data", "~> 2.2"
4242

43-
# Use native llhttp for MRI (more performant) and llhttp-ffi for other interpreters (better compatibility)
44-
if RUBY_ENGINE == "ruby"
45-
spec.add_dependency "llhttp", "~> 0.6.1"
46-
else
43+
if RUBY_ENGINE == "jruby"
44+
spec.platform = "java"
4745
spec.add_dependency "llhttp-ffi", "~> 0.5.1"
46+
else
47+
spec.add_dependency "llhttp", "~> 0.6.1"
4848
end
4949
end

0 commit comments

Comments
 (0)