minify-html/.github/workflows/ruby.yml

86 lines
2.5 KiB
YAML
Raw Normal View History

2020-01-19 03:19:33 -05:00
name: Build, package, and upload Ruby gem
on:
create:
tags:
- 'v*'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
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
- 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
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
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}
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'
- name: Download Linux built library
uses: actions/download-artifact@v1
with:
name: linux
path: ruby/lib/linux
2020-01-19 03:19:33 -05:00
- 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
2020-01-19 03:19:33 -05:00
working-directory: ./ruby
run: |
gem build hyperbuild.gemspec
2020-01-19 08:33:39 -05:00
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