.github/workflows/release.yml
name: Release
on:
push:
branches:
- main
permissions:
contents: read
jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: false
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: bundle exec rubocop --parallel
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Check spelling with codespell
run: codespell --ignore-words=codespell.txt || exit 1
unit_test:
runs-on: ubuntu-latest
needs: [rubocop, codespell]
strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2']
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run RSpec
run: bundle exec rspec
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: unit-ruby-${{matrix.ruby }}
parallel: true
path-to-lcov: ./coverage/lcov/http-auth0.lcov
finish:
needs: unit_test
runs-on: ubuntu-latest
steps:
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
file: ./coverage/lcov/http-auth0.lcov
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
needs: [unit_test]
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/release-please-action@v3
id: release
with:
token: ${{ secrets.DEVOPS_TOKEN }}
release-type: ruby
version-file: lib/http/auth0/version.rb
bootstrap-sha: 0e38bc3d108db2ba2bdcb1a6e553d7e7730c03fc
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false},{"type":"docs","section":"Documentation","hidden":true},{"type":"test","section":"Tests","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"ci","section":"Miscellaneous","hidden":true}]'
- name: Push to Release Branch
if: ${{ steps.release.outputs.release_created }}
uses: actions/github-script@v6
env:
MAJOR_VERSION: ${{ steps.release.outputs.major }}
with:
github-token: ${{ secrets.DEVOPS_TOKEN }}
script: |
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${process.env.MAJOR_VERSION}-stable`,
sha: context.sha,
force: true
});