Skip to content

Commit 36783c4

Browse files
authored
Update workflows to check Changelog and build gem (#73)
Closes #67 Added workflows to * Lint * Check changelog * Build & publish the gem Also * Regenerated Rubocop todo
1 parent b0877e1 commit 36783c4

File tree

6 files changed

+125
-8
lines changed

6 files changed

+125
-8
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and publish
2+
3+
on:
4+
workflow_call: {}
5+
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: read
13+
env:
14+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_6.1.gemfile
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
bundler-cache: true
22+
23+
- name: Build gem
24+
run: bundle exec rake build
25+
26+
- name: Archive coverage
27+
if: success()
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: gem-pkg
31+
path: pkg/*.gem
32+
33+
publish:
34+
name: Publish
35+
needs: build
36+
if: github.ref_type == 'tag'
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: read
40+
packages: write
41+
42+
steps:
43+
- name: Set up Ruby
44+
uses: ruby/setup-ruby@v1
45+
with:
46+
ruby-version: '3.2'
47+
48+
- uses: actions/download-artifact@v4
49+
with:
50+
name: gem-pkg
51+
path: pkg/
52+
53+
- name: Publish to GPR
54+
run: |
55+
mkdir -p $HOME/.gem
56+
touch $HOME/.gem/credentials
57+
chmod 0600 $HOME/.gem/credentials
58+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
59+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} pkg/*.gem
60+
env:
61+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
62+
OWNER: ${{ github.repository_owner }}
63+

.github/workflows/changelog.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Changelog
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
changelog-updated:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 1
15+
- name: Check if changelog updated
16+
id: changed-files-specific
17+
uses: tj-actions/changed-files@v44
18+
with:
19+
base_sha: ${{ github.event.pull_request.base.sha }}
20+
files: |
21+
CHANGELOG.md
22+
env:
23+
GITHUB_TOKEN: ${{ github.token }}
24+
25+
- name: Fail job if changelog not updated
26+
if: steps.changed-files-specific.outputs.any_changed == 'false'
27+
run: |
28+
exit 1
29+

.github/workflows/ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
5+
branches:
6+
- '**'
7+
tags:
8+
- '**'
89

910
jobs:
1011
test:
1112
if: github.ref_type == 'branch' && github.ref_name != 'main'
1213
uses: ./.github/workflows/test.yml
13-
# code_quality:
14-
# if: github.ref_type == 'branch' && github.ref_name != 'main'
15-
# uses: ./.github/workflows/code_quality.yml
14+
15+
code_quality:
16+
if: github.ref_type == 'branch' && github.ref_name != 'main'
17+
uses: ./.github/workflows/code_quality.yml
18+
19+
build_publish:
20+
uses: ./.github/workflows/build_publish.yml

.github/workflows/code_quality.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Code quality'
2+
on:
3+
workflow_call: {}
4+
5+
jobs:
6+
rubocop:
7+
name: Rubocop
8+
runs-on: ubuntu-latest
9+
env:
10+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_7.2.gemfile
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: ruby/setup-ruby@v1
15+
with:
16+
bundler-cache: true
17+
18+
- name: Inspecting with Rubocop
19+
run: bundle exec rubocop
20+

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
env:
2222
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
2323
steps:
24-
- uses: actions/checkout@v3
25-
24+
- uses: actions/checkout@v4
2625
- name: Set up Ruby
2726
uses: ruby/setup-ruby@v1
2827
with:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
### Fixed
13+
- Reinstated static code analysis checks in CI (#73)
1314

1415
### Removed
1516

0 commit comments

Comments
 (0)