87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
name: Build, package, and upload Ruby gem
|
|
|
|
on:
|
|
create:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest]
|
|
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
|
|
- name: Set up Ruby (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: sudo apt install -y ruby2.5 ruby2.5-dev
|
|
- name: Set up Ruby (macOS)
|
|
if: runner.os == 'macOS'
|
|
run: brew install ruby@2.5
|
|
- name: Set up Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
default: true
|
|
- name: Build Ruby native library
|
|
run: cargo build --release
|
|
working-directory: ./ruby
|
|
- name: Upload built library
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: ${{ matrix.NAME }}
|
|
path: ./ruby/target/release/${{ matrix.FILE }}
|
|
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'
|
|
- name: Download Linux built library
|
|
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
|
|
working-directory: ./ruby
|
|
run: |
|
|
cp ../README.md .
|
|
gem build hyperbuild.gemspec
|
|
mkdir -p "$HOME/.gem"
|
|
echo '---' > "$HOME/.gem/credentials"
|
|
echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" >> "$HOME/.gem/credentials"
|
|
chmod 0600 "$HOME/.gem/credentials"
|
|
gem push hyperbuild-${{ steps.version.outputs.VERSION }}.gem
|