-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Test coverage and automate publish (#213)
- Loading branch information
1 parent
4133883
commit a283340
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+* | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
- name: Install dependencies | ||
run: bundle install | ||
- name: Build | ||
run: gem build *.gemspec | ||
- name: 'Upload Artifact' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: gems | ||
path: '*.gem' | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
strategy: | ||
matrix: | ||
ruby-version: ['2.6', '2.7', '3.0', '3.1'] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Ruby latest | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
- name: Install dependencies | ||
run: bundle install | ||
- name: Run tests and collect coverage | ||
run: bundle exec rake | ||
- name: Upload coverage to Codecov | ||
if: ${{ matrix.ruby-version == 3.1 }} | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ${{ github.workspace }}/coverage/coverage.xml | ||
publish: | ||
name: Publish | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
needs: [build, test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: sudo apt-get install -y oathtool | ||
- name: Download all workflow run artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: gems | ||
path: gems | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
- name: Publish gems to Rubygems | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${GEM_API_KEY}\n" > $HOME/.gem/credentials | ||
gem push gems/*.gem | ||
env: | ||
GEM_API_KEY: ${{secrets.GEM_API_KEY}} |
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
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