92 lines
3.2 KiB
YAML
92 lines
3.2 KiB
YAML
name: Build and publish Ruby gem
|
|
|
|
on:
|
|
create:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest]
|
|
ruby: [2.5.7, 2.6.5, 2.7.0]
|
|
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
|
|
# Install Ruby manually as actions/setup-ruby@v1 does not compile with `--enable-shared`.
|
|
- name: Prepare for rbenv
|
|
run: |
|
|
cat << 'EOF' >> "$HOME/.bash_profile"
|
|
export PATH="$HOME/.rbenv/bin:$PATH"
|
|
eval "$(rbenv init -)"
|
|
EOF
|
|
- name: Set up rbenv (macOS)
|
|
if: runner.os == 'macOS'
|
|
shell: bash -l {0}
|
|
run: brew install rbenv
|
|
- name: Set up rbenv (Linux)
|
|
if: runner.os == 'Linux'
|
|
shell: bash -l {0}
|
|
run: |
|
|
sudo apt install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev
|
|
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
|
|
shell: bash -l {0}
|
|
run: |
|
|
rbenv install ${{ matrix.ruby }}
|
|
rbenv global ${{ matrix.ruby }}
|
|
- name: Set up Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
default: true
|
|
- name: Build Ruby native library
|
|
shell: bash -l {0}
|
|
run: cargo build --release
|
|
working-directory: ./ruby
|
|
- 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
|
|
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:
|
|
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}
|
|
- name: Set up Ruby
|
|
uses: actions/setup-ruby@v1
|
|
with:
|
|
ruby-version: '2.5'
|
|
- uses: chrislennon/action-aws-cli@v1.1
|
|
- name: Pack and publish gem
|
|
working-directory: ./ruby
|
|
run: |
|
|
cp ../README.md .
|
|
aws s3 mv s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/ ./lib/. --recursive
|
|
gem build hyperbuild.gemspec
|
|
mkdir -p "$HOME/.gem"
|
|
cat << 'EOF' > "$HOME/.gem/credentials"
|
|
---
|
|
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
EOF
|
|
chmod 0600 "$HOME/.gem/credentials"
|
|
gem push hyperbuild-${{ steps.version.outputs.VERSION }}.gem
|