Skip to content

Commit 5cef591

Browse files
committed
Compile native gem(s)
Signed-off-by: retorted <201078195+retorted@users.noreply.github.com>
1 parent e189a63 commit 5cef591

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.github/workflows/post-release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Builds and pushes precompiled gem versions to Rubygems when a new release tag is created.
2+
# Eg; creating/pushing a new tag `0.2.21` will generate and publish:
3+
# - itsi-server-0.2.21-x86_64-linux.gem
4+
# - itsi-scheduler-0.2.21-x86_64-linux.gem
5+
# - itsi-server-0.2.21-arm64-darwin.gem
6+
# - itsi-scheduler-0.2.21-arm64-darwin.gem
7+
8+
name: Post-Release
9+
10+
on:
11+
push:
12+
tags: ["*"]
13+
14+
jobs:
15+
compile-native:
16+
strategy:
17+
matrix:
18+
include:
19+
- runner: ubuntu-22.04
20+
platform: x86_64-linux
21+
flags: "target-cpu=native"
22+
- runner: macos-15
23+
platform: arm64-darwin23
24+
flags: "target-cpu=apple-m4"
25+
runs-on: ${{ matrix.runner }}
26+
env:
27+
BUNDLE_WITHOUT: test
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
31+
with:
32+
ruby-version: 3.1
33+
bundler-cache: true
34+
cargo-cache: true
35+
36+
- name: Compile gem for ${{ matrix.platform }}
37+
run: bundle exec rake precompile:${{ matrix.platform }}
38+
env:
39+
RUSTFLAGS: "-C ${{ matrix.flags }}"
40+
41+
- name: Push to RubyGems
42+
run: |
43+
mkdir -p ~/.gem
44+
echo -e "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
45+
chmod 0600 ~/.gem/credentials
46+
gem push pkg/*.gem
47+
env:
48+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}

Rakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ task :build_all do
8383
end
8484
end
8585

86+
namespace :precompile do
87+
%i[x86_64-linux arm64-darwin23].each do |platform|
88+
task platform do
89+
Rake::Task[:sync_crates].invoke
90+
GEMS.each do |gem_info|
91+
Dir.chdir(gem_info[:dir]) do
92+
system("rake native:#{platform} gem") or raise 'Gem build failed'
93+
built_gem = Dir["pkg/*.gem"].first
94+
FileUtils.mkdir_p('../../pkg')
95+
FileUtils.mv(built_gem, "../../#{built_gem.sub('-23.gem', '.gem')}")
96+
end
97+
end
98+
end
99+
end
100+
end
101+
86102
task :test_env_up do
87103
system('terraform -chdir=tmp/sandbox/deploy apply')
88104
end

0 commit comments

Comments
 (0)