Skip to content

Commit

Permalink
Ship JRuby gem pre-built
Browse files Browse the repository at this point in the history
Use Github-Actions to build gems for **all conceivable versions**.

Fixes ConradIrwin#22

Signed-off-by: Stavros Ntentos <[email protected]>
  • Loading branch information
stdedos committed Oct 1, 2024
1 parent 74f8a47 commit f36b36d
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build Gems

on:
push:
pull_request:
release:
types:
- published

jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
ruby-version:
- 'head'
- '3.4'
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- '2.4'
- '2.3'
- '2.2'
- '2.1'
- '2.1.0'
- '2.0.0'
- '1.9'
- '1.9.3'
- '1.9.2'
# - '1.8(.7)'
- 'jruby-head'
- 'jruby-9.4'
- 'jruby-9.3'
- 'jruby-9.2'
- 'jruby-9.1'
# - 'jruby-1[89]mode'
- truffleruby-24
- truffleruby-23
- truffleruby-22
- truffleruby-21
- truffleruby-20
- truffleruby-19
- truffleruby+graalvm-24
- truffleruby+graalvm-23
- truffleruby+graalvm-22
- truffleruby+graalvm-21
# - rbx ?
# - ree ?

defaults:
run:
shell: /bin/bash --noprofile --norc -Eeuxo pipefail {0}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JRuby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Slugify GITHUB_REPOSITORY
run: echo "GITHUB_REPOSITORY_SLUG=${GITHUB_REPOSITORY////_}" >> $GITHUB_ENV

- name: Build Extension (JRuby or CRuby)
run: |
if [[ "${{ matrix.ruby-version }}" == jruby* ]]; then
# For JRuby, compile the Java file without Gradle
javac -d ./ext/org/pryrepl/ ./ext/org/pryrepl/InterceptionEventHook.java
else
# For CRuby, build the C extension
ruby ext/extconf.rb
make
fi
- name: Package Gem with Pre-built JAR (for JRuby)
if: startsWith(matrix.ruby-version, 'jruby')
run: |
# Copy the compiled class files into the appropriate directory
jar cf ./ext/org/pryrepl/InterceptionEventHook.jar -C ./ext/org/pryrepl/ .
- name: Package Gem with Pre-built JAR
run: rake build

- name: Run Tests
run: |
bundle exec rake test
- name: Build Gem
run: gem build your_gem.gemspec

- name: Create artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: ${{ env.GITHUB_REPOSITORY_SLUG }}_${{ github.event_name }}_${{ github.event.pull_request.number || github.sha }}_${{ matrix.os
}}_ruby-${{ matrix.ruby-version }}_gems
path: ${{ github.event.repository.name }}-*.gem

0 comments on commit f36b36d

Please sign in to comment.