Skip to content

Commit 45f9c94

Browse files
committed
build: Adjust ruby release process
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
1 parent 9515907 commit 45f9c94

3 files changed

Lines changed: 62 additions & 3 deletions

File tree

.github/workflows/ruby-release.yml

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ on:
44
push:
55
tags:
66
- ruby-v*
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: "Build and smoke-test the gems without publishing them"
11+
type: boolean
12+
default: true
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
717

818
jobs:
919
cross-gem:
@@ -15,6 +25,7 @@ jobs:
1525
matrix:
1626
platform:
1727
- aarch64-linux
28+
- aarch64-linux-musl
1829
- arm64-darwin
1930
- x64-mingw-ucrt
2031
- x86_64-darwin
@@ -31,6 +42,11 @@ jobs:
3142
bundler-cache: true
3243
working-directory: ./bindings/ruby
3344

45+
# `cross-gem` reads `rb_sys` version from the root `Gemfile.lock`, and
46+
# falls back to the newest published one when it is missing.
47+
- name: Expose Gemfile.lock for rb-sys-dock version detection
48+
run: cp bindings/ruby/Gemfile.lock Gemfile.lock
49+
3450
- name: Compile native gem
3551
id: cross-gem
3652
uses: oxidize-rb/actions/cross-gem@v1.4.4
@@ -39,6 +55,22 @@ jobs:
3955
ruby-versions: "3.2,3.3,3.4,4.0"
4056
working-directory: ./bindings/ruby
4157

58+
# Pushes to RubyGems are irreversible.
59+
- name: Smoke test
60+
if: matrix.platform == 'x86_64-linux'
61+
working-directory: ./bindings/ruby
62+
env:
63+
BUNDLE_GEMFILE: ""
64+
run: |
65+
gem install pkg/*.gem --local --no-document
66+
ruby -e "
67+
require 'css_inline'
68+
html = '<html><head><style>h1 { color: red; }</style></head><body><h1>Test</h1></body></html>'
69+
result = CSSInline.inline(html)
70+
raise 'inlining failed' unless result.include?('style=\"color: red;\"')
71+
puts 'smoke test OK'
72+
"
73+
4274
- uses: actions/upload-artifact@v7
4375
with:
4476
name: cross-gem-${{ matrix.platform }}
@@ -48,6 +80,9 @@ jobs:
4880
ruby-release:
4981
needs: cross-gem
5082
runs-on: ubuntu-22.04
83+
env:
84+
# A manual run from a branch has no version to release.
85+
PUBLISH: ${{ !inputs.dry_run && startsWith(github.ref, 'refs/tags/') }}
5186

5287
steps:
5388
- uses: actions/checkout@v7
@@ -69,7 +104,15 @@ jobs:
69104
merge-multiple: true
70105
path: ./bindings/ruby/pkg
71106

107+
- name: Build source gem
108+
working-directory: ./bindings/ruby
109+
run: |
110+
gem build *.gemspec
111+
mv css_inline-*.gem pkg/
112+
ls -l pkg/
113+
72114
- name: GitHub Release
115+
if: env.PUBLISH == 'true'
73116
uses: softprops/action-gh-release@v3
74117
with:
75118
make_latest: false
@@ -78,15 +121,23 @@ jobs:
78121
files: ./bindings/ruby/pkg/*.gem
79122

80123
- name: Publish to RubyGems
124+
if: env.PUBLISH == 'true'
125+
working-directory: ./bindings/ruby
81126
run: |
82127
mkdir -p $HOME/.gem
83128
touch $HOME/.gem/credentials
84129
chmod 0600 $HOME/.gem/credentials
85130
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
86-
cd ./bindings/ruby
87-
gem build *.gemspec
88-
for gem in *.gem pkg/*.gem; do
131+
for gem in pkg/*.gem; do
89132
gem push "$gem"
90133
done
91134
env:
92135
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
136+
137+
- name: Upload gems (no publish)
138+
if: env.PUBLISH != 'true'
139+
uses: actions/upload-artifact@v7
140+
with:
141+
name: gems
142+
path: ./bindings/ruby/pkg/*.gem
143+
if-no-files-found: error

bindings/ruby/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Precompiled native gems for Linux (glibc & musl, x86-64 & aarch64), macOS (x86-64 & arm64), and Windows (`x64-mingw-ucrt`). Installing no longer requires a Rust toolchain on these platforms.
8+
- Support for Ruby 4.0.
9+
510
## [0.21.2] - 2026-08-24
611

712
### Fixed

bindings/ruby/Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ spec.required_ruby_version = nil
1212
spec.required_rubygems_version = nil
1313
spec.extensions.clear
1414
spec.files -= Dir["ext/**/*"]
15+
# `rb_sys` only builds the extension.
16+
spec.dependencies.reject! { |d| d.name == "rb_sys" }
1517

1618
Rake::ExtensionTask.new("css_inline", spec) do |c|
1719
c.lib_dir = "lib/css_inline"
1820
c.cross_compile = true
1921
c.cross_platform = [
2022
"aarch64-linux",
23+
"aarch64-linux-musl",
2124
"arm64-darwin",
2225
"x64-mingw-ucrt",
2326
"x64-mingw32",

0 commit comments

Comments
 (0)