Skip to content

Commit 536bc1d

Browse files
authored
Extract ruby-gem composite action (#13)
1 parent 0f3613f commit 536bc1d

File tree

5 files changed

+82
-15
lines changed

5 files changed

+82
-15
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: build-ruby-gem
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
name: Ruby ${{ matrix.ruby }}
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
ruby:
14+
- 3.0
15+
- 3.1
16+
- 3.2
17+
- 3.3
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: 'Test ruby gem action'
21+
uses: ./build-ruby-gem
22+
with:
23+
workdir: build-ruby-gem/test
24+
ruby: ${{ matrix.ruby }}

.github/workflows/ruby-gem.yml

+7-15
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,17 @@ jobs:
4141
gemfile: ${{ fromJSON(inputs.gemfiles) }}
4242
bundler: ${{ fromJSON(inputs.bundler) }}
4343
exclude: ${{ fromJSON(inputs.exclude)}}
44-
env:
45-
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
46-
BUNDLER_VERSION: "${{ matrix.bundler }}"
47-
RAILS_ENV: test
4844
steps:
4945
- uses: actions/checkout@v3
50-
- name: Set up Ruby
51-
uses: ruby/setup-ruby@v1
52-
with:
53-
bundler-cache: true
54-
bundler: ${{ matrix.bundler }}
55-
ruby-version: ${{ matrix.ruby }}
56-
working-directory: ${{ inputs.workdir }}
5746
- name: Before build
5847
if: ${{ inputs.before_build != '' }}
5948
run: "${{ inputs.before_build }}"
60-
- name: Run the build script
61-
working-directory: ${{ inputs.workdir }}
62-
run: bundle exec rake
49+
- uses: powerhome/github-actions-workflows/build-ruby-gem@main
50+
with:
51+
workdir: ${{ inputs.workdir }}
52+
ruby: ${{ matrix.ruby }}
53+
gemfile: ${{ matrix.gemfile }}
54+
bundler: ${{ matrix.bundler }}
6355

6456
license-compliance:
6557
uses: ./.github/workflows/license-compliance.yml
@@ -72,7 +64,7 @@ jobs:
7264
if: ${{ contains(github.ref, 'refs/tags/v') && contains(github.ref, inputs.package) }}
7365
steps:
7466
- uses: actions/checkout@v3
75-
- uses: powerhome/publish-rubygems-action@git-safe-directory
67+
- uses: cadwallion/publish-rubygems-action@master
7668
env:
7769
RELEASE_COMMAND: rake build release:guard_clean release:rubygem_push
7870
RUBYGEMS_API_KEY: ${{ secrets.rubygems_api_key }}

build-ruby-gem/action.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Ruby Gem"
2+
description: "Power Home ruby gem build"
3+
inputs:
4+
workdir:
5+
description: 'The working directory during this build'
6+
required: false
7+
ruby:
8+
description: 'The ruby version to use on this build'
9+
default: '3.3'
10+
required: false
11+
gemfile:
12+
description: 'The path to a Gemfile, relative to workdir'
13+
default: 'Gemfile'
14+
required: false
15+
bundler:
16+
description: 'Bundler major version'
17+
default: '2'
18+
required: false
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- name: 'Set up Ruby'
23+
uses: ruby/setup-ruby@v1
24+
env:
25+
BUNDLE_GEMFILE: '${{ inputs.gemfile }}'
26+
BUNDLER_VERSION: '${{ inputs.bundler }}'
27+
RAILS_ENV: 'test'
28+
with:
29+
bundler-cache: true
30+
bundler: '${{ inputs.bundler }}'
31+
ruby-version: '${{ inputs.ruby }}'
32+
working-directory: '${{ inputs.workdir }}'
33+
- name: 'Run the build script'
34+
env:
35+
BUNDLE_GEMFILE: '${{ inputs.gemfile }}'
36+
BUNDLER_VERSION: '${{ inputs.bundler }}'
37+
RAILS_ENV: 'test'
38+
working-directory: '${{ inputs.workdir }}'
39+
shell: 'bash'
40+
run: 'bundle exec rake'

build-ruby-gem/test/Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem "rake", ">= 13.0"

build-ruby-gem/test/Rakefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env rake
2+
3+
# frozen_string_literal: true
4+
5+
task :default do
6+
puts "Default task invoked successfully"
7+
puts "Ruby: #{RUBY_VERSION}"
8+
end

0 commit comments

Comments
 (0)