Create a gem skeleton.
Bundler: How to create a Ruby gem with Bundler
bundle gem my-gem
Create a random binary data.
# 2GB data dd if=/dev/urandom of=blob bs=1m count=2000
Modify .gemspec
file.
- Fill
TODO
fields allowed_push_host
is https://rubygems.pkg.github.com/- Include blob to
spec.files
# frozen_string_literal: true require_relative "lib/my/gem/version" Gem::Specification.new do |spec| spec.name = "my-gem" spec.version = My::Gem::VERSION spec.authors = ["Kensuke Nagae"] spec.email = ["kyanny@gmail.com"] spec.summary = ": Write a short summary, because RubyGems requires one." spec.description = ": Write a longer description or delete this line." spec.homepage = "https://example.com/" spec.required_ruby_version = ">= 2.4.0" spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://example.com/" spec.metadata["changelog_uri"] = "https://example.com/changelog" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) } + ['blob'] end spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] # Uncomment to register a new dependency of your gem # spec.add_dependency "example-gem", "~> 1.0" # For more information and examples about making a new gem, checkout our # guide at: https://bundler.io/guides/creating_gem.html end
Build a gem.
gem build my-gem.gemspec
Check the gem size.
❯ ls -lah -rw-r--r-- 1 kyanny staff 1.9G 10 21 17:31 blob -rw-r--r-- 1 kyanny staff 1.9G 10 21 18:15 my-gem-0.1.0.gem -rw-r--r-- 1 kyanny staff 1.4K 10 21 17:34 my-gem.gemspec
Publish to GitHub Packages RubyGems registry
Working with the RubyGems registry - GitHub Docs
Set a credentials.
~/.gem/credentials:
--- :github: Bearer TOKEN
Push the gem.
- OWNER is
username
- Repository
my-gem
must exist
gem push --key github --host https://rubygems.pkg.github.com/OWNER my-gem-0.0.1.gem