Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions .github/workflows/ruby-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ on:
push:
tags:
- ruby-v*
workflow_dispatch:
inputs:
dry_run:
description: "Build and smoke-test the gems without publishing them"
type: boolean
default: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
cross-gem:
Expand All @@ -15,6 +25,7 @@ jobs:
matrix:
platform:
- aarch64-linux
- aarch64-linux-musl
- arm64-darwin
- x64-mingw-ucrt
- x86_64-darwin
Expand All @@ -31,6 +42,11 @@ jobs:
bundler-cache: true
working-directory: ./bindings/ruby

# `cross-gem` reads `rb_sys` version from the root `Gemfile.lock`, and
# falls back to the newest published one when it is missing.
- name: Expose Gemfile.lock for rb-sys-dock version detection
run: cp bindings/ruby/Gemfile.lock Gemfile.lock

- name: Compile native gem
id: cross-gem
uses: oxidize-rb/actions/cross-gem@v1.4.4
Expand All @@ -39,6 +55,22 @@ jobs:
ruby-versions: "3.2,3.3,3.4,4.0"
working-directory: ./bindings/ruby

# Pushes to RubyGems are irreversible.
- name: Smoke test
if: matrix.platform == 'x86_64-linux'
working-directory: ./bindings/ruby
env:
BUNDLE_GEMFILE: ""
run: |
gem install pkg/*.gem --local --no-document
ruby -e "
require 'css_inline'
html = '<html><head><style>h1 { color: red; }</style></head><body><h1>Test</h1></body></html>'
result = CSSInline.inline(html)
raise 'inlining failed' unless result.include?('style=\"color: red;\"')
puts 'smoke test OK'
"

- uses: actions/upload-artifact@v7
with:
name: cross-gem-${{ matrix.platform }}
Expand All @@ -48,6 +80,9 @@ jobs:
ruby-release:
needs: cross-gem
runs-on: ubuntu-22.04
env:
# A manual run from a branch has no version to release.
PUBLISH: ${{ !inputs.dry_run && startsWith(github.ref, 'refs/tags/') }}

steps:
- uses: actions/checkout@v7
Expand All @@ -69,7 +104,15 @@ jobs:
merge-multiple: true
path: ./bindings/ruby/pkg

- name: Build source gem
working-directory: ./bindings/ruby
run: |
gem build *.gemspec
mv css_inline-*.gem pkg/
ls -l pkg/

- name: GitHub Release
if: env.PUBLISH == 'true'
uses: softprops/action-gh-release@v3
with:
make_latest: false
Expand All @@ -78,15 +121,23 @@ jobs:
files: ./bindings/ruby/pkg/*.gem

- name: Publish to RubyGems
if: env.PUBLISH == 'true'
working-directory: ./bindings/ruby
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
cd ./bindings/ruby
gem build *.gemspec
for gem in *.gem pkg/*.gem; do
for gem in pkg/*.gem; do
gem push "$gem"
done
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"

- name: Upload gems (no publish)
if: env.PUBLISH != 'true'
uses: actions/upload-artifact@v7
with:
name: gems
path: ./bindings/ruby/pkg/*.gem
if-no-files-found: error
5 changes: 5 additions & 0 deletions bindings/ruby/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Added

- 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.
- Support for Ruby 4.0.

## [0.21.2] - 2026-08-24

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions bindings/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ spec.required_ruby_version = nil
spec.required_rubygems_version = nil
spec.extensions.clear
spec.files -= Dir["ext/**/*"]
# `rb_sys` only builds the extension.
spec.dependencies.reject! { |d| d.name == "rb_sys" }

Rake::ExtensionTask.new("css_inline", spec) do |c|
c.lib_dir = "lib/css_inline"
c.cross_compile = true
c.cross_platform = [
"aarch64-linux",
"aarch64-linux-musl",
"arm64-darwin",
"x64-mingw-ucrt",
"x64-mingw32",
Expand Down
Loading