chore(ruby): Resolve CI failure during aarch64-linux native build #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Native Ruby Gem | ||
| on: | ||
| workflow_dispatch: | ||
| jobs: | ||
| build-shared-library-binaries: | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, macos-13, windows-latest] | ||
| include: | ||
| # Config for Linux | ||
| - os: ubuntu-latest | ||
| platform_tasks: "compile:aarch64-linux compile:x86_64-linux" | ||
| artifact_name: "linux-binaries" | ||
| artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/*-linux/" | ||
| # Config for macOS (Apple Silicon + Intel) | ||
| # Note: macos-13 is an Intel runner (x86_64) but can cross-compile to Apple Silicon (aarch64) | ||
| - os: macos-13 | ||
| platform_tasks: "compile:aarch64-darwin compile:x86_64-darwin" | ||
| artifact_name: "darwin-binaries" | ||
| artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/*-darwin/" | ||
| # Config for Windows | ||
| - os: windows-latest | ||
| platform_tasks: "compile:x64-mingw32" | ||
| artifact_name: "windows-binaries" | ||
| artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/x64-mingw32/" | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: 1.25.x | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.3' | ||
| bundler-cache: true | ||
| working-directory: 'spannerlib/wrappers/spannerlib-ruby' | ||
| - name: Install cross-compilers (Linux) | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| sudo apt-get update | ||
| # GCC cross toolchain and binutils for aarch64 | ||
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu | ||
| # Mingw-w64 cross toolchain for Windows target (x86_64) | ||
| sudo apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 | ||
| echo "=== cross compiler versions ===" | ||
| aarch64-linux-gnu-gcc --version || true | ||
| aarch64-linux-gnu-g++ --version || true | ||
| x86_64-w64-mingw32-gcc --version || true | ||
| which aarch64-linux-gnu-gcc || true | ||
| which x86_64-w64-mingw32-gcc || true | ||
| # The cross-compiler step for macOS is removed, | ||
| # as the built-in Clang on macOS runners can handle both Intel and ARM. | ||
| - name: Compile Binaries | ||
| working-directory: spannerlib/wrappers/spannerlib-ruby | ||
| run: | | ||
| # This runs the specific Rake tasks for this OS | ||
| # e.g., "rake compile:aarch64-linux compile:x86_64-linux" | ||
| bundle exec rake ${{ matrix.platform_tasks }} | ||
| - name: Upload Binaries as Artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.artifact_name }} | ||
| path: ${{ matrix.artifact_path }} | ||
| publish: | ||
| name: Package and Publish Gem | ||
| # This job runs only after all 'build' jobs have succeeded | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| # This gives the job permission to publish to RubyGems | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.3' | ||
| bundler-cache: true | ||
| working-directory: 'spannerlib/wrappers/spannerlib-ruby' | ||
| - name: Download all binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| # No name means it downloads ALL artifacts from this workflow | ||
| # The binaries will be placed in their original paths | ||
| path: spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ | ||
| - name: List downloaded files (for debugging) | ||
| run: ls -R spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ | ||
| - name: Build Gem | ||
| working-directory: spannerlib/wrappers/spannerlib-ruby | ||
| run: gem build spannerlib-ruby.gemspec | ||
| - name: Publish to RubyGems | ||
| working-directory: spannerlib/wrappers/spannerlib-ruby | ||
| run: | | ||
| # Make all built .gem files available to be pushed | ||
| mkdir -p $HOME/.gem | ||
| touch $HOME/.gem/credentials | ||
| chmod 0600 $HOME/.gem/credentials | ||
| # This uses the new "Trusted Publishing" feature. | ||
| # https://guides.rubygems.org/publishing/#publishing-with-github-actions | ||
| printf -- "---\n:rubygems_api_key: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
| # Push the gem | ||
| gem push *.gem | ||
| env: | ||
| GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||