The process is easy, but not well documented. I usually rely on my bash history to remember the different steps, but today,
history | grep "gem push" gave me an empty result. So I decided that a blog post was more reliable than a self-deleting history.
The process presented below is the same for creating or updating your gem. In the example below, we use
1.2.0 as examples, they will need to be adapted to fit your needs.
Before starting the release process, you need to make sure the code you are about to publish is working as expected.
Have a look at the git history, make sure you are updated with the latest version of the main branch. Launching the tests is also a good idea.
First: update the version. It is specified in the gemspec file. You will need to open it with an editor:
And then update the version definition:
s.version = '1.2.0'
When choosing the new version, remember to follow the semantic versioning policies.
The version is also duplicated into
Gemfile.lock. You can only update the CHANGELOG, if you maintain one.
Once the version is bumped, you can commit the changes:
git commit -m "v1.2.0" git push
Once the version is updated, even if non-necessary, it is good to create a new tag. To do so, in your terminal, execute:
git tag -a v1.2.0 -m "Changelog..." git push origin v1.2.0
Tags are useful because they help other developers to see exactly which version of the code is associated to which version.
Every release can be fetched with
A specific version can be checked-out with
git checkout v1.2.0.
Tags will also be listed in a specific page on GitHub, highlighting each release.
Now the version was bumped and tagged, you can now proceed by publishing it to RubyGem.
First, you need to build a
gem build safe-pg-migrations
Once created, the file can be finally published. If you haven't done it already, you will need to create an account at https://rubygems.org/users/new.
gem push safe-pg-migrations-1.2.0.gem
This last step will take a few seconds to complete. You should receive an email shortly after, confirming that a new release was published.
Congratulation, you have published a new version of your gem!
If you find any most effective way to release, make sure to let us know in the comments!
Cover picture by Pierre Emmanuel Poublanc