Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Update CI pipeline (#57) #62

Update CI pipeline (#57)

Update CI pipeline (#57) #62

name: Test, build, and release Ruby gem
on:
push:
branches: [master]
workflow_dispatch:
pull_request:
branches: [master]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ '2.7', '3.0', '3.1' ]
steps:
- uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Setup
run: |
bundle install
- name: Test
run: bundle exec rake
build-release-pipeline:
runs-on: ubuntu-latest
needs: test
if: success() && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup
run: |
bundle install
- name: Build
id: build
run: |
bundle exec rake build
run: echo "GEM_VERSION=v$(bundle exec rake version)" >> $GITHUB_ENV
- name: Release
if: success() && github.ref == 'refs/heads/master'
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push pkg/*
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
- name: Tag repo with new gem version
if: success() && github.ref == 'refs/heads/master'
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.GEM_VERSION }}",
sha: context.sha
})