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

136 lines
4.9 KiB
YAML
Raw Normal View History

name: Build and publish Ruby gem
2020-01-19 03:19:33 -05:00
on:
create:
tags:
- 'v*'
2020-06-18 21:06:22 -04:00
repository_dispatch:
types: [wf-ruby]
2020-01-19 03:19:33 -05:00
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
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
- name: Get version
id: version
shell: bash
2020-06-18 22:22:28 -04:00
run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
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: |
cat << 'EOF' >> "$HOME/.bash_profile"
2020-01-20 01:48:17 -05:00
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
EOF
- name: Get native module file name
id: native_file
shell: bash
env:
RUBY_VERSION: ${{ matrix.ruby }}
# PowerShell doesn't support `${...}` syntax.
run: echo ::set-output name=NAME::${{ matrix.NAME }}-ruby${RUBY_VERSION%.*}
2020-01-20 01:48:17 -05:00
- name: Set up rbenv (macOS)
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}
# rbenv-installer now uses Linux brew to install Ruby, which we do not want.
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
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
mkdir -p "$HOME/.rbenv/plugins"
git clone https://github.com/rbenv/ruby-build.git "$HOME/.rbenv/plugins/ruby-build"
2020-01-20 01:48:17 -05:00
- 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-07-10 15:52:31 -04:00
- name: Set up Rust (macOS, Linux)
if: runner.os != 'Windows'
2020-01-19 03:19:33 -05:00
uses: actions-rs/toolchain@v1
with:
toolchain: stable
2020-01-19 03:19:33 -05:00
profile: minimal
default: true
2020-07-10 15:52:31 -04:00
- name: Set up Rust (Windows)
if: runner.os == 'Windows'
uses: actions-rs/toolchain@v1
with:
toolchain: stable-gnu
profile: minimal
default: true
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.14.0'
2020-07-10 15:52:31 -04:00
- name: Set up GCC (Windows)
if: runner.os == 'Windows'
run: .\.github\workflows\gcc.ps1
2020-01-19 03:19:33 -05:00
- 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-06-18 19:49:48 -04:00
- name: Install B2 CLI (macOS, Linux)
if: runner.os != 'Windows'
run: |
sudo pip install setuptools
sudo pip install --upgrade b2
- name: Install B2 CLI (Windows)
if: runner.os == 'Windows'
run: |
pip install --upgrade b2
- name: Upload to B2
run: |
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
2020-06-18 21:38:56 -04:00
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./ruby/target/release/${{ matrix.FILE }} 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
2020-06-18 22:22:28 -04:00
run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
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-06-18 19:49:48 -04:00
- name: Install B2 CLI
run: |
sudo pip install setuptools
sudo pip install --upgrade b2
- name: Pack and publish gem
2020-01-19 03:19:33 -05:00
working-directory: ./ruby
run: |
2020-01-19 09:13:21 -05:00
cp ../README.md .
2020-06-18 19:49:48 -04:00
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
b2 sync b2://${{ secrets.CICD_CLI_B2_BUCKET_NAME }}/hyperbuild/bin/ruby/${{ steps.version.outputs.VERSION }}/ ./lib/.
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
chmod 0600 "$HOME/.gem/credentials"
2020-06-18 21:44:54 -04:00
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
gem push hyperbuild-${{ steps.version.outputs.VERSION }}.gem
fi