Build Ruby per version

This commit is contained in:
Wilson Lin 2020-01-20 17:48:17 +11:00
parent a45ff036c8
commit de9fab6f41
3 changed files with 30 additions and 33 deletions

View File

@ -11,6 +11,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
ruby: [2.5.7, 2.6.5, 2.7.0]
include: include:
- os: ubuntu-latest - os: ubuntu-latest
NAME: linux NAME: linux
@ -20,12 +21,24 @@ jobs:
FILE: 'libhyperbuild_ruby_lib.dylib' FILE: 'libhyperbuild_ruby_lib.dylib'
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Set up Ruby (Linux) - name: Prepare for rbenv
if: runner.os == 'Linux' run: |
run: sudo apt install -y ruby2.5 ruby2.5-dev cat << 'EOF' >> "$HOME/.bashrc"
- name: Set up Ruby (macOS) export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
EOF
- name: Set up rbenv (macOS)
if: runner.os == 'macOS' if: runner.os == 'macOS'
run: brew install ruby@2.5 run: brew install rbenv
- name: Set up rbenv (Linux)
if: runner.os == 'Linux'
run: |
wget -O install-rbenv.sh https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer
bash install-rbenv.sh || true # Ignore rbenv-doctor.
- name: Set up Ruby
run: |
rbenv install ${{ matrix.ruby }}
rbenv global ${{ matrix.ruby }}
- name: Set up Rust - name: Set up Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -35,11 +48,14 @@ jobs:
- name: Build Ruby native library - name: Build Ruby native library
run: cargo build --release run: cargo build --release
working-directory: ./ruby working-directory: ./ruby
- name: Upload built library - uses: chrislennon/action-aws-cli@v1.1
uses: actions/upload-artifact@v1 - name: Upload to S3
with: env:
name: ${{ matrix.NAME }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
path: ./ruby/target/release/${{ matrix.FILE }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
RUBY_VERSION: ${{ matrix.ruby }}
run: aws s3 cp ./ruby/target/release/${{ matrix.FILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}-ruby${RUBY_VERSION%.*}
package: package:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
@ -53,31 +69,12 @@ jobs:
uses: actions/setup-ruby@v1 uses: actions/setup-ruby@v1
with: with:
ruby-version: '2.5' ruby-version: '2.5'
- name: Download Linux built library - uses: chrislennon/action-aws-cli@v1.1
uses: actions/download-artifact@v1
with:
name: linux
path: ruby/lib/linux
- name: Download macOS built library
uses: actions/download-artifact@v1
with:
name: macos
path: ruby/lib/macos
- name: Move native library files to correct location
shell: bash
working-directory: ./ruby/lib
run: |
for f in *; do
if [ -d "$f" ]; then
mv $f/* "$f.nativelib"
rmdir "$f"
mv "$f.nativelib" "$f"
fi
done
- name: Package and publish gem - name: Package and publish gem
working-directory: ./ruby working-directory: ./ruby
run: | run: |
cp ../README.md . cp ../README.md .
aws s3 mv s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/ ./lib/. --recursive
gem build hyperbuild.gemspec gem build hyperbuild.gemspec
mkdir -p "$HOME/.gem" mkdir -p "$HOME/.gem"
cat << 'EOF' > "$HOME/.gem/credentials" cat << 'EOF' > "$HOME/.gem/credentials"

View File

@ -160,7 +160,7 @@ Add the library as a dependency to `Gemfile` or `*.gemspec`.
```ruby ```ruby
require 'hyperbuild' require 'hyperbuild'
print hyperbuild.minify "<p> Hello, world! </p>" print Hyperbuild.minify "<p> Hello, world! </p>"
``` ```
</details> </details>

View File

@ -11,7 +11,7 @@ class HyperbuildLoader
end end
def self.lib_path def self.lib_path
File.join(__dir__, operating_system) File.join(__dir__, [operating_system, '-x86_64-ruby', RUBY_VERSION.split('.')[0...-1].join('.')].join(''))
end end
end end