ngelx/resource_quotable

View on GitHub
.github/workflows/release.yml

Summary

Maintainability
Test Coverage
name: Build and Release

on:
  push:
    branches:
      - master

permissions:
  contents: write
  pull-requests: write

jobs:
  release-gem:
    runs-on: ubuntu-latest
    steps:
      - uses: GoogleCloudPlatform/release-please-action@v3
        id: release
        with:
          # The release type
          release-type: ruby
          # A name for the artifact releases are being created for
          # which is the name of our gem
          package-name: resource_quotable
          # Should breaking changes before 1.0.0 produce minor bumps?
          bump-minor-pre-major: true
          # Path to our version file to increment
          version-file: "lib/resource_quotable/version.rb"
          changelog-path: "Changelog.md"

      # Checkout code if release was created
      - uses: actions/checkout@v2
        if: ${{ steps.release.outputs.release_created }}

      # Setup ruby if a release was created
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.7
          bundler-cache: true
        if: ${{ steps.release.outputs.release_created }}

      - name: Setup Code Climate test-reporter
        run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build
        if: ${{ steps.release.outputs.release_created }}

      - name: Run Rspec
        run: |
          bundle exec rake
        if: ${{ steps.release.outputs.release_created }}

      - name: Publish code coverage
        run: |
          export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
          ./cc-test-reporter after-build -r ${{secrets.CC_TEST_REPORTER_ID}}
        if: ${{ steps.release.outputs.release_created }}

      # Publish
      - name: publish gem
        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:
          # Make sure to update the secret name
          # if yours isn't named RUBYGEMS_AUTH_TOKEN
          GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
        if: ${{ steps.release.outputs.release_created }}