2020-01-20 03:42:45 -05:00
|
|
|
name: Build and publish Ruby gem
|
2020-01-19 03:19:33 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
create:
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-01-19 07:24:54 -05:00
|
|
|
os: [ubuntu-latest, macos-latest]
|
2020-01-20 01:48:17 -05:00
|
|
|
ruby: [2.5.7, 2.6.5, 2.7.0]
|
2020-01-19 03:19:33 -05:00
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
NAME: linux
|
|
|
|
FILE: 'libhyperbuild_ruby_lib.so'
|
|
|
|
- os: macos-latest
|
|
|
|
NAME: macos
|
|
|
|
FILE: 'libhyperbuild_ruby_lib.dylib'
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
2020-01-20 08:27:58 -05:00
|
|
|
- name: Get version
|
|
|
|
id: version
|
|
|
|
shell: bash
|
|
|
|
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
2020-01-20 05:55:17 -05:00
|
|
|
# Install Ruby manually as actions/setup-ruby@v1 does not compile with `--enable-shared`.
|
2020-01-20 01:48:17 -05:00
|
|
|
- name: Prepare for rbenv
|
|
|
|
run: |
|
2020-01-20 05:01:57 -05:00
|
|
|
cat << 'EOF' >> "$HOME/.bash_profile"
|
2020-01-20 01:48:17 -05:00
|
|
|
export PATH="$HOME/.rbenv/bin:$PATH"
|
|
|
|
eval "$(rbenv init -)"
|
|
|
|
EOF
|
2020-01-20 08:15:26 -05:00
|
|
|
- name: Get native module file name
|
|
|
|
id: native_file
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
RUBY_VERSION: ${{ matrix.ruby }}
|
|
|
|
# PowerShell doesn't support `${...}` syntax.
|
2020-01-20 08:27:58 -05:00
|
|
|
run: echo ::set-output name=NAME::${{ matrix.NAME }}-ruby${RUBY_VERSION%.*}
|
2020-01-20 01:48:17 -05:00
|
|
|
- name: Set up rbenv (macOS)
|
2020-01-19 07:24:54 -05:00
|
|
|
if: runner.os == 'macOS'
|
2020-01-20 04:44:47 -05:00
|
|
|
shell: bash -l {0}
|
2020-01-20 08:42:24 -05:00
|
|
|
run: |
|
|
|
|
brew install openssl libyaml libffi
|
|
|
|
brew install rbenv
|
2020-01-20 01:48:17 -05:00
|
|
|
- name: Set up rbenv (Linux)
|
|
|
|
if: runner.os == 'Linux'
|
2020-01-20 04:44:47 -05:00
|
|
|
shell: bash -l {0}
|
2020-01-20 01:48:17 -05:00
|
|
|
run: |
|
2020-01-20 05:10:58 -05:00
|
|
|
sudo apt install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev
|
2020-01-20 01:48:17 -05:00
|
|
|
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
|
2020-01-20 04:44:47 -05:00
|
|
|
shell: bash -l {0}
|
2020-01-20 01:48:17 -05:00
|
|
|
run: |
|
|
|
|
rbenv install ${{ matrix.ruby }}
|
|
|
|
rbenv global ${{ matrix.ruby }}
|
2020-01-19 03:19:33 -05:00
|
|
|
- name: Set up Rust
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
profile: minimal
|
|
|
|
default: true
|
|
|
|
- name: Build Ruby native library
|
2020-01-20 04:44:47 -05:00
|
|
|
shell: bash -l {0}
|
2020-01-19 03:19:33 -05:00
|
|
|
run: cargo build --release
|
|
|
|
working-directory: ./ruby
|
2020-01-20 01:48:17 -05:00
|
|
|
- uses: chrislennon/action-aws-cli@v1.1
|
|
|
|
- name: Upload to S3
|
|
|
|
env:
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
AWS_REGION: us-west-2
|
2020-01-20 08:15:26 -05:00
|
|
|
run: aws s3 cp ./ruby/target/release/${{ matrix.FILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/${{ steps.native_file.outputs.NAME }}
|
2020-01-19 03:19:33 -05:00
|
|
|
package:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- name: Get version
|
|
|
|
id: version
|
|
|
|
shell: bash
|
|
|
|
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
2020-01-19 03:25:11 -05:00
|
|
|
- name: Set up Ruby
|
2020-01-19 03:19:33 -05:00
|
|
|
uses: actions/setup-ruby@v1
|
|
|
|
with:
|
|
|
|
ruby-version: '2.5'
|
2020-01-20 01:48:17 -05:00
|
|
|
- uses: chrislennon/action-aws-cli@v1.1
|
2020-01-20 03:42:45 -05:00
|
|
|
- name: Pack and publish gem
|
2020-01-19 03:19:33 -05:00
|
|
|
working-directory: ./ruby
|
2020-01-20 08:09:51 -05:00
|
|
|
env:
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
AWS_REGION: us-west-2
|
2020-01-19 08:23:57 -05:00
|
|
|
run: |
|
2020-01-19 09:13:21 -05:00
|
|
|
cp ../README.md .
|
2020-01-20 01:48:17 -05:00
|
|
|
aws s3 mv s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/ ./lib/. --recursive
|
2020-01-19 08:23:57 -05:00
|
|
|
gem build hyperbuild.gemspec
|
2020-01-19 08:33:39 -05:00
|
|
|
mkdir -p "$HOME/.gem"
|
2020-01-19 23:10:34 -05:00
|
|
|
cat << 'EOF' > "$HOME/.gem/credentials"
|
|
|
|
---
|
|
|
|
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
|
|
EOF
|
2020-01-19 08:23:57 -05:00
|
|
|
chmod 0600 "$HOME/.gem/credentials"
|
|
|
|
gem push hyperbuild-${{ steps.version.outputs.VERSION }}.gem
|