Hasty Briefsbeta

Bilingual

How to License and Distribute a Private Ruby Gem

2 days ago
  • The blog post is outdated but still useful for S3-compatible distribution; Keygen now offers an official Rubygems engine.
  • Keygen can be used to license and distribute private Ruby gems, similar to previous guides for Docker, Node packages, and Electron apps.
  • The open-core licensing model (e.g., Sidekiq Pro) is a popular business model for commercial gems.
  • Steps to build a Ruby gem: create directory structure, define class, create gemspec, build the gem using `gem build`.
  • Generate a private gem source index using `gem generate_index` to produce required files (specs, quick spec, etc.).
  • Publish the gem to Keygen using the Keygen CLI: set environment variables, create a release, upload artifacts (gem, index files, quick spec), then publish and tag the release.
  • Install the gem by adding a Gemfile source with a license token in the URL (e.g., `https://license:TOKEN@api.keygen.sh/...`).
  • The process can be automated with a Rakefile for easy publishing of new gem versions.