Publish a Ruby gem
In general, the gem name should be the same as the thing you require when using
it. This means using
_, and not
- to separate multi-word gem names. See the
name your gem guide for more detailed
Follow the guidelines on semver.org for assigning version numbers.
Versions should only be changed in a commit of their own, in a pull request of their own.
This alerts team members to the new version and allows for last-minute scrutiny before the new version is released. Also, by raising a separate pull request, we avoid version number conflicts between feature branches.
We should follow the scheme used by Bundler when creating gems (see this railscast).
- The version is stored in a file by itself in
- The Gemfile references the gemspec for gem dependencies. All gem dependencies should be specified in the gemspec.
- The Gemfile.lock is never committed (it should be in the
Releasing gem versions
The default Jenkins build script will automatically detect the presence of a
gemspec file and publish the gem to rubygems.org. See the
Jenkinsfile for govuk-lint
for an example.
Clearing the gemstash cache
When a new gem version is released, it may not be available immediately on Jenkins.
This is due to gemstash, our gem mirror. It caches versions for up to 30
minutes. To force it to clear, run this on
apt-1.management in the relevant
$ sudo docker restart gemstash
To clear the cache for the CI Jenkins instance, run this in integration.