Skip to content

Commit

Permalink
GitHub Actions init
Browse files Browse the repository at this point in the history
  • Loading branch information
amancevice committed Sep 8, 2023
1 parent 631d67f commit 69ff512
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/actions/setup-rubygems/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Setup RubyGems
description: Setup RubyGems credentials
inputs:
rubygems_api_key:
description: RubyGems API key
required: true
runs:
using: composite
steps:
- run: mkdir -p ~/.gem
shell: bash
- run: |
cat <<-YAML > ~/.gem/credentials
---
:rubygems_api_key: ${{ inputs.rubygems_api_key }}
YAML
shell: bash
- run: chmod 0600 ~/.gem/credentials
shell: bash
15 changes: 15 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test
description: Run tests
inputs:
activesupport-version:
description: ActiveSupport version constraint
required: true
runs:
using: composite
steps:
- run: bundle add activesupport -v '${{ inputs.activesupport-version }}'
shell: bash
- run: bundle install
shell: bash
- run: bundle exec rake
shell: bash
40 changes: 40 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test and Release
on:
pull_request:
push:
release:
types:
- published
jobs:
test:
name: Test [Ruby ${{ matrix.ruby-version }}]
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- "2.7"
- "3.1"
- "3.2"
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- run: bundle install
- run: bundle exec rake test
push:
name: Publish Gem
if: ${{ github.event.release }}
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- uses: ./.github/actions/setup-rubygems
with:
rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
- run: bundle install
- run: bundle exec rake gem:push
21 changes: 20 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
require "rubygems"
require "bundler/setup"
require "bundler/gem_tasks"
require 'rake/testtask'

task :default => :test

Rake::TestTask.new do |t|
t.pattern = "spec/*_spec.rb"
end

namespace :gem do
require 'bundler/gem_tasks'

@gem = "pkg/egads-#{ Egads::VERSION }.gem"

desc "Push #{ @gem } to rubygems.org"
task :push => %i[test build git:check] do
sh %{gem push #{ @gem }}
end
end

namespace :git do
desc 'Check git workspace'
task :check do
sh %{git diff HEAD --quiet} do |ok|
abort "\e[31mRefusing to continue - git workspace is dirty\e[0m" unless ok
end
end
end

0 comments on commit 69ff512

Please sign in to comment.