How to create a Github Action to publish a Ruby gem to Rubygems.org
Step #1 | Generate Rubygems API Key
Log in to your rubygems.org account
Go to Settings
Click on API KEYS
Click New API key
Copy your key in a safe place you can't retrieve it from rubygems.org later.
Step #3 | Create a Secret for your GitHub repository
In your Github repository, go to Settings
Go to Secrets from the sidebar
Press New repository secret button
In the Name field put: GEM_HOST_API_KEY
In the Value field put your rubygems API key
Press Add secret button
Step #4 | Create a GitHub Action
In your repository, Go to Actions tab
Press New workflow
Select set up a workflow yourself
Paste the following in it and save
This will create a file under your repository root directory .github/workflows/gem-push.yml
5. Under your repository root directory create .ruby-version
file and put the ruby version you desire
6. Under your repository root directory create .versionrc.js
file and put the following
This script will update your repository version
Step # 5 | Run your Action's workflow
Go to Actions tab
Select the workflow and press Run.
Resources
Last updated