Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflows to check Changelog and build gem #73

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build and publish

on:
workflow_call: {}

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_6.1.gemfile
steps:
- uses: actions/checkout@v4

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

- name: Build gem
run: bundle exec rake build

- name: Archive coverage
if: success()
uses: actions/upload-artifact@v4
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@v4
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
20 changes: 20 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Code quality'
on:
workflow_call: {}

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_6.1.gemfile
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Inspecting with Rubocop
run: bundle exec 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
* Workflow to automatically lint, check the changelog, and build & publish the gem (#73)

## [v3.6.0]

### Added
Expand Down
Loading