Skip to content

[Rust][Ruby] Add methods to get metadata for features #19

[Rust][Ruby] Add methods to get metadata for features

[Rust][Ruby] Add methods to get metadata for features #19

name: "[Ruby] Cross-Build"
on:
push:
branches: [ "main" ]
paths:
- ".github/workflows/ruby_cross-build.yml"
- "ruby/**"
- "rust/**"
pull_request:
branches: [ "main" ]
paths:
- ".github/workflows/ruby_cross-build.yml"
- "ruby/**"
- "rust/**"
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RB_SYS_CARGO_PROFILE: release
jobs:
# Following example from https://github.com/oxidize-rb/actions/blob/main/cross-gem
# Hopefully this builds the gem for multiple Ruby versions.
ci-data:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
- uses: oxidize-rb/actions/fetch-ci-data@v1
id: fetch
with:
# Can see versions using `curl https://cache.ruby-lang.org/pub/misc/ci_versions/cruby.json`
# We don't need the latest bleeding edge.
stable-ruby-versions: |
exclude: [head]
cross-gem:
name: "Build"
runs-on: ubuntu-latest
needs: ci-data
strategy:
fail-fast: true
matrix:
ruby_platform:
# Add more as needed.
# More versions in https://raw.githubusercontent.com/oxidize-rb/rb-sys/main/data/derived/github-actions-matrix.json
- aarch64-linux
- arm64-darwin
- x86_64-linux
steps:
- uses: actions/checkout@v4
# This is file is mainly for local development and to help Sorbet.
# It should not be needed for the build as we'll set a specific version of Ruby.
- name: "rm .ruby-version"
shell: bash
run: |
rm .ruby-version
working-directory: ./ruby/optify
- uses: ruby/setup-ruby@v1
name: "[Ruby] Setup"
with:
bundler-cache: true
# The version to use to run rb-sys, but the cross-gem step will use a Docker container with it's own Ruby version, I think.
ruby-version: "3.4.1"
# Don't put the working-directory here because we don't want to install the Ruby project in this context.
# Initialize some Rust resources
# such as ensuring that /home/runner/.cargo/registry is created.
# Otherwise, we get "docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/runner/.cargo/registry."
- name: "[Rust] Build"
run: cargo check --release
working-directory: ./rust/optify
# Documentation: https://github.com/oxidize-rb/actions/blob/main/cross-gem
# Outputs: gem-path
- uses: oxidize-rb/actions/cross-gem@main
id: cross-build
name: "[Ruby] Cross-Build"
with:
cache-save-always: false
platform: ${{ matrix.ruby_platform }}
# Available versions: https://cache.ruby-lang.org/pub/misc/ci_versions/cruby.json
# Found in https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb
# If we want to go back to specific supported versions, we can use the following:
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
# Tried doing this, but it said ">= 3.0, < 3.1.dev" on rubygems.
# Tried ">=3.0, < 4", but RubyGems said: ">= 3.0, < 3.1.dev"
working-directory: ./ruby/optify
- name: "[Ruby] Publish"
if: github.ref == 'refs/heads/main'
shell: bash
# It probably just fails if the gem is already published.
# We want to only be lenient for the `gem push`, but we would still want to clearly see that an issue happened during the run.
continue-on-error: true
run: |
set -ex
gem_path="${{ steps.cross-build.outputs.gem-path }}"
ls -lh "${gem_path}"
gem push "${gem_path}"
sha256sum "${gem_path}"
env:
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'