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
818jobs :
919 cross-gem :
1525 matrix :
1626 platform :
1727 - aarch64-linux
28+ - aarch64-linux-musl
1829 - arm64-darwin
1930 - x64-mingw-ucrt
2031 - x86_64-darwin
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
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 }}
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
0 commit comments