Skip to content

Commit

Permalink
Update workflows to check Changelog and build gem
Browse files Browse the repository at this point in the history
  • Loading branch information
patch0 committed Jul 4, 2024
1 parent ba2ceab commit 842361e
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 9 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and publish

on:
workflow_call: {}

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: read

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Build gem
run: rake build

- name: Archive coverage
if: success()
uses: actions/upload-artifact@v3
with:
name: gem-pkg
path: pkg/*.gem

publish:
name: Publish
needs: build
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'

- uses: actions/download-artifact@v3
with:
name: gem-pkg
path: pkg/

- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} pkg/*.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}

29 changes: 29 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Changelog

on:
pull_request:
branches:
- '**'

jobs:
changelog-updated:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check if changelog updated
id: changed-files-specific
uses: tj-actions/changed-files@v44
with:
base_sha: ${{ github.event.pull_request.base.sha }}
files: |
CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Fail job if changelog not updated
if: steps.changed-files-specific.outputs.any_changed == 'false'
run: |
exit 1
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches:
- '**'
tags:
- '**'

jobs:
test:
if: github.ref_type == 'branch' && github.ref_name != 'main'
uses: ./.github/workflows/test.yml
# code_quality:
# if: github.ref_type == 'branch' && github.ref_name != 'main'
# uses: ./.github/workflows/code_quality.yml

code_quality:
if: github.ref_type == 'branch' && github.ref_name != 'main'
uses: ./.github/workflows/code_quality.yml

build_publish:
uses: ./.github/workflows/build_publish.yml
11 changes: 11 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Code quality'
on:
workflow_call

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Inspecting with Rubocop
run: rubocop

6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -32,7 +32,7 @@ jobs:

- name: Archive coverage
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-ruby_${{ matrix.ruby-version }}-${{ matrix.gemfile }}
path: ${{ github.workspace }}/coverage/
Expand All @@ -43,7 +43,7 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: code-coverage-report-ruby_3.2-rails_7.1
path: coverage/
Expand Down

0 comments on commit 842361e

Please sign in to comment.