This is a mobile version, full one is here.
Yegor Bugayenko
26 August 2014
How to Publish to RubyGems, in One Click
When I release a new version of jgd, a Ruby gem, to RubyGems.org, it takes 30 seconds of my time. Here is how I released a bug fix for version 1.5.1, in GitHub issue #6:
As you see, I gave a command to Rultor, and it released a new version to RubyGems. I didn’t do anything else.
Now let’s see how you can do the same. How you can configure your project so that the release of its new version to RubyGems.org takes just a few seconds of your time.
By the way, I assume that you’re hosting your project in GitHub. If not, this entire tutorial won’t work. If you are still not in GitHub, I would strongly recommend moving there.
Create RubyGems Account
Create an account in RubyGems.org.
Create rubygems.yml
Create a rubygems.yml
file (you may already have it as ~/.gem/credentials
):
:rubygems_api_key: d355d8940bb031bfe9acf03ed3da4c0d
You should get this API key from RubyGems. To find your API key, click on your user name when logged in to RubyGems.org and then click on “Edit Profile.”
Encrypt rubygems.yml
Now, encrypt rubygems.yml
with a rultor remote:
$ gem install rultor
$ rultor encrypt -p me/test rubygems.yml
Instead of me/test
use the name of your GitHub project.
You will get a new file rubygems.yml.asc
.
Add this file to the root directory of your project,
commit and push. The file contains your secret information,
but only the Rultor server can decrypt it.
Prepare Gemspec
In your gemspec
file, make sure you use 1.0.snapshot
as a version number:
# coding: utf-8
Gem::Specification.new do |s|
# ...
s.version = '1.0.snapshot'
# ...
end
This version name will be replaced by Rultor during deployment.
Configure Rultor
Create a .rultor.yml
file in the root directory of your project:
decrypt:
rubygems.yml: "repo/rubygems.yml.asc"
release:
script: |
rm -rf *.gem
sed -i "s/1.0.snapshot/${tag}/g" foo.gemspec
gem build foo.gemspec
chmod 0600 /home/r/rubygems.yml
gem push *.gem --config-file /home/r/rubygems.yml
In this example, replace foo
with the name of your gem.
Run It!
Now it’s time to see how it all works. Create a new ticket in the GitHub issue tracker, and post something like that into it (read more about Rultor commands):
@rultor release, tag is `0.1`
You will get a response in a few seconds. The rest will be done by Rultor.
Enjoy!
BTW, if something doesn’t work as I’ve explained, don’t hesitate to submit a ticket to Rultor issue tracker. I will try to help you.