Prepare CI with GitHub actions for publishing #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CI | |
on: | |
push: | |
tags: ['v*'] | |
branches: [master] | |
pull_request: | |
branches: ['**'] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby: | |
- '2.1' | |
- '2.3' | |
- '2.4' | |
- '2.5' | |
- '2.6' | |
- '2.7' | |
- '3.0' | |
- '3.1' | |
- '3.2' | |
- '3.3' | |
- jruby-head | |
- truffleruby-head | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
- run: bundle exec rspec --format doc | |
- uses: codecov/codecov-action@v3 | |
if: matrix.ruby == '3.2' | |
with: | |
files: coverage/coverage.xml | |
yard: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.7' | |
bundler-cache: true | |
- run: bundle exec yardoc --fail-on-warning | |
check_version: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.7' | |
bundler-cache: true | |
- run: bin/check-version | |
release: | |
needs: [test, yard, check_version] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Publish to RubyGems | |
run: | | |
mkdir -p $HOME/.gem | |
touch $HOME/.gem/credentials | |
chmod 0600 $HOME/.gem/credentials | |
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
gem build *.gemspec | |
gem push *.gem | |
env: | |
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}" |