Skip to content

Commit

Permalink
.github: build native gem
Browse files Browse the repository at this point in the history
Build a native gem with pre-compiled .so files so that users wouldn't
have to install the Rust compiler and everything else.
  • Loading branch information
GiedriusS committed Mar 27, 2024
1 parent 8e2b695 commit 062cab8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_release_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Build gem
if: success() && github.ref == 'refs/heads/master'
run: |
gem build prometheus-client-mmap.gemspec
bundle exec rake gem:x86_64-linux
echo "::set-output name=gem_version::v$(bundle exec rake version)"
- name: Release to rubygems
if: success() && github.ref == 'refs/heads/master'
Expand All @@ -35,7 +35,7 @@ jobs:
touch $HOME/.gem/credentials
chmod 600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push vinted-prometheus-client-mmap-*.gem -V
gem push pkg/vinted-prometheus-client-mmap-*.gem -V
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
- name: Tag repo with new gem version
Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ namespace "gem" do
ENV["RCD_IMAGE"] = "rbsys/#{plat}:#{RbSys::VERSION}"

RakeCompilerDock.sh <<~SH, platform: plat
(mkdir "$HOME/.protoc") ||: &&
curl -L https://github.com/protocolbuffers/protobuf/releases/download/v24.4/protoc-24.4-linux-x86_64.zip -o "$HOME/.protoc/protoc-24.4-linux-x86_64.zip" &&
cur="$(pwd)" &&
cd "$HOME/.protoc"; unzip -o protoc-24.4-linux-x86_64.zip &&
cd "$cur" &&
export PATH="${PATH}:$HOME/.protoc/bin" &&
bundle && \
RUBY_CC_VERSION="#{cross_rubies.join(":")}" \
rake native:#{plat} pkg/#{gemspec.full_name}-#{plat}.gem
Expand Down

0 comments on commit 062cab8

Please sign in to comment.