Skip to content

Publish to Rubygems.org #10

Publish to Rubygems.org

Publish to Rubygems.org #10

name: Publish to Rubygems.org
on:
workflow_dispatch:
jobs:
build:
name: Build, Test & Publish Gem to Rubygems.org
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
# Set up the latest version of Ruby
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
# Install dependencies
- name: Install Dependencies
run: |
gem install bundler
bundle install
# Run RSpec tests
- name: Run RSpec
run: bundle exec rspec --backtrace
# Publish to RubyGems if tests pass
- name: Publish to RubyGems
if: success()
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.PHCDEV_RUBYGEMS_TOKEN}}"