Release your ruby gems with ease.
This gem plugin aims at making gem development easier by automating repetitive work based on conventions, configuration, and templates.
It adds the commands bootstrap, gemspec, bump, tag and a release to the rubygems gem command.
| Project | Gem Release |
|---|---|
| Gem name | gem-release |
| License | MIT |
| Version | |
| Continuous integration | |
| Test coverage | |
| Documentation | Documentation |
| Credits | Contributors |
This gif demos some of the things you can do with this plugin:
The gem provides a rubygems plugin, so it's just:
gem install gem-releaseDefaults for all options can be specified in a config file at either one of these locations:
~/.gem_release/config.yml~/.gem_release.yml./.gem_release/config.yml./.gem_release.ymlConfig files must be in the YAML format, and list options per command. Common options can be set on the root.
For instance, the following entries will set the quiet flag for all commands,
and a custom host name with gem release:
quiet: true
release:
host: https://example.comDefaults for all options also can be specified as environment variables, for
example GEM_RELEASE_PRETEND=true.
Defaults specified in config files and environment variables can be overridden
as command line options when issuing the respective gem command.
Only the first config file found in the locations given above will be used, if any, and defaults from this config file will be merged with both environment variables and given command line options.
When bootstrapping a new gem:
gem_name is left untouched when mapped to the path lib/gem_name, and the Ruby constant name GemName.gem-name is mapped to the path lib/gem/name, and the Ruby constant name Gem::NameWhen bumping the version of an existing gem gem-name the following locations are checked:
lib/gem/name/version.rblib/gem-name/version.rbOutput depends on a tty being available or not. I.e. when run as an
individual command colorized human readable output will be printed (see the
Demo screencast above). When attached to a pipe then output is kept simple and
parsable.
E.g.:
$ gem bump --pretend | cat
bump gem-release 1.0.0 1.0.1
git_add lib/gem/release/version.rb
git_commit "Bump gem-release to 1.0.1"This is useful, for example, for grabbing the next version number:
$ gem bump --pretend --no-commit | awk '{ print $4 }'
1.0.1The gem gem-release adds the following commands to the rubygems gem command:
Scaffolds a new gem from template files.
gem_name - name of the gem (optional, will default to the current directory name if not specified)…Scaffolds a new gem from template files. Optionally initialize a git repository, set a git remote, and push to the remote repository.
If no argument is given the current directory name is used as the gem name. If one or many arguments are given then these will be used as gem names, and new directories will be created accordingly.
By default the following files will be created:
.gitignoreGemspec[gem-name].gemspecLICENSE.mdlib/[gem]/[name].rblib/[gem]/[name]/version.rbTemplates in the first existing one of these directories will always be used to create additional files:
./.gem-release/default (local)~/.gem-release/default (global)If --template [group] is given additional files will be created from
the first existing one of these directories:
./.gem-release/[group] (local)~/.gem-release/[group] (global)It is possible to specify several template groups in order to add files from several custom template directories.
If --template rspec is given then additionally the files .rspec
and spec/spec_helper.rb will be created, or whatever files exist in
a local or global directory .gem-release/templates/rspec.
If --template travis is given then additionally the file
.travis.yml will be created, or whatever files exist in a local or
global directory .gem-release/templates/travis.
The license added by default is the MIT License. If --license [name]
is given then this license will be added. The only other license file
shipped is the Mozilla Public License v2.0. Other licenses must be
present in the local or global directory .gem-release/licenses. If
--no-license is given then no license will be added.
Bumps one, several, or all gems in this directory.
gem_name - name of the gem (optional, will use the directory name, or all gemspecs if --recurse is given)…Bumps the version number defined in lib/[gem_name]/version.rb to a given, specific version number, or to the next major, minor, patch, or pre-release level.
Optionally it pushes to the origin repository. Also, optionally it
invokes the gem tag and/or gem release command.
If no argument is given the first gemspec's name is assumed as the gem
name. If one or many arguments are given then these will be used as
gem names. If --recurse is given then all gem names from all
gemspecs in this directory or any of its subdirectories will be used.
The version can be bumped to either one of these targets:
major
1.1.1 # Bump to the given, specific version number
major # Bump to the next major level (e.g. 0.0.1 to 1.0.0)
minor # Bump to the next minor level (e.g. 0.0.1 to 0.1.0)
patch # Bump to the next patch level (e.g. 0.0.1 to 0.0.2)
pre|rc|etc # Bump to the next pre-release level (e.g. 0.0.1 to
# 0.1.0.pre.1, 1.0.0.pre.1 to 1.0.0.pre.2)When searching for the version file for a gem named gem-name: the
following paths will be searched relative to the gemspec's directory.
lib/gem-name/version.rblib/gem/name/version.rbGenerates a gemspec.
gem_name - name of the gem (optional, will default to the current directory name if not specified) --[no]-bin Add bin files directive to the gemspec (defaults to true if a ./bin directory exists)
--dir DIR Directory to place the gem in (defaults to the given name, or the current working dir)
-l, --[no-]license NAMES License(s) to list in the gemspec
-s, --strategy Strategy for collecting files [glob|git] in gemspec (default: glob)
--[no-]color
--pretendGenerates a gemspec.
If no argument is given the current directory name is used as the gem name. If one or many arguments are given then these will be used as gem names, and new directories will be created accordingly.
The generated gemspec file will use the glob strategy for finding
files by default. Known strategies are:
glob - uses the glob pattern {bin/*,lib/**/*,[A-Z]*}git - uses the git command git ls-files app libReleases one or all gems in this directory.
gem_name - name of the gem (optional, will use the first gemspec, or all gemspecs if --recurse is given)…Builds one or many gems from the given gemspec(s), pushes them to rubygems.org (or another, compatible host), and removes the left over gem file.
Optionally invoke gem tag.
If no argument is given the first gemspec's name is assumed as the gem
name. If one or many arguments are given then these will be used. If
--recurse is given then all gem names from all gemspecs in this
directory or any of its subdirectories will be used.
Tags the HEAD commit with the gem's current version.
-p, --[no-]push Push tag to the remote git repository
--remote REMOTE Git remote to push to (default: origin)
-s, --sign GPG sign the tag
--[no-]color
--pretendCreates an annotated tag for the current HEAD commit, using the gem's current version.
Optionally pushes the tag to the origin repository.
If one or many arguments are given then gemspecs with the same names
will be searched, and the working directory changed to their
respective directories. If --recurse is given then the directories
all gem names from all gemspecs in this directory or any of its
subdirectories will be used. This assumes that these directories are
separate git repositories.
The tag name will be v[version]. For example, if the current
version is 1.0.0, then The tag is created using the command git tag -am "tag v1.0.0" v1.0.0.
cd /tmp
rm -rf foo
gem bootstrap foo
cd foo
tree -a -I .git.
├── Gemfile
├── LICENSE.md
├── foo.gemspec
└── lib
├── foo
│ └── version.rb
└── foo.rb# this bumps foo
cd /tmp/foo; gem bump
# this also bumps foo
cd /tmp/foo; gem bump foocd /tmp
rm -rf foo bar
gem bootstrap foo
cd foo
gem bootstrap bar --dir .
tree -a -I .git.
├── Gemfile
├── LICENSE.md
├── bar.gemspec
├── foo.gemspec
└── lib
├── bar
│ └── version.rb
├── bar.rb
├── foo
│ └── version.rb
└── foo.rb# this bumps both foo and bar
cd /tmp/foo; gem bump --recurse
# this also bumps both foo and bar
cd /tmp/foo; gem bump foo bar
# this bumps foo (because it's the first gemspec found)
cd /tmp/foo; gem bump
# this bumps foo
cd /tmp/foo; gem bump foo
# this bumps bar
cd /tmp/foo; gem bump barcd /tmp
rm -rf root
mkdir root
cd root
gem bootstrap foo
gem bootstrap bar
tree -a -I .git.
├── bar
│ ├── Gemfile
│ ├── LICENSE.md
│ ├── bar.gemspec
│ └── lib
│ ├── bar
│ │ └── version.rb
│ └── bar.rb
└── foo
├── Gemfile
├── LICENSE.md
├── foo.gemspec
└── lib
├── foo
│ └── version.rb
└── foo.rb# this bumps both foo and bar
cd /tmp/root; gem bump --recurse
# this also bumps both foo and bar
cd /tmp/root; gem bump foo bar
# this does bumps both foo and bar
cd /tmp/root; gem bump
# this bumps foo
cdNo open issues yet, or sync has not completed.