Giter Club home page Giter Club logo

gem-release's Introduction

gem release

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 Gem Version
Continuous integration GitHub Build Status
Test coverage Coverage Status
Documentation Documentation
Credits Contributors

Table of contents

Demo

This gif demos some of the things you can do with this plugin:

gem-release-demo

Installation

The gem provides a rubygems plugin, so it's just:

gem install gem-release

Configuration

Defaults 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.yml

Config 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.com

Defaults 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.

Conventions

When bootstrapping a new gem:

  • A gem name gem_name is left untouched when mapped to the path lib/gem_name, and the Ruby constant name GemName.
  • A gem name gem-name is mapped to the path lib/gem/name, and the Ruby constant name Gem::Name

When bumping the version of an existing gem gem-name the following locations are checked:

  • lib/gem/name/version.rb
  • lib/gem-name/version.rb

Piping

Output 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.1

Reference

The gem gem-release adds the following commands to the rubygems gem command:

  • gem bootstrap - Scaffolds a new gem from template files.
  • gem bump - Bumps one, several, or all gems in this directory.
  • gem gemspec - Generates a gemspec.
  • gem release - Releases one or all gems in this directory.
  • gem tag - Tags the HEAD commit with the gem's current version.

gem bootstrap

Scaffolds a new gem from template files.

Arguments

gem_name - name of the gem (optional, will default to the current directory name if not specified)

Options

    --[no-]scaffold              Scaffold gem files (default: true)
    --dir DIR                    Directory to place the gem in (defaults to the given name, or the current working dir)
    --bin                        Create an executable ./bin/[name], add executables directive to .gemspec
-t, --template NAME              Template groups to use for scaffolding
    --rspec                      Use the rspec group (by default adds .rspec and spec/spec_helper.rb)
    --travis                     Use the travis group (by default adds .travis.yml)
-l, --[no-]license NAME          License(s) to add (default: mit)
-s, --strategy NAME              Strategy for collecting files [glob|git] in .gemspec (default: glob)
    --[no-]git                   Initialize a git repo (default: true)
    --github                     Initialize a git repo, create on github
    --remote                     Git remote repository
    --push                       Push the git repo to github
    --[no-]color
    --pretend

Description

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:

  • .gitignore
  • Gemspec
  • [gem-name].gemspec
  • LICENSE.md
  • lib/[gem]/[name].rb
  • lib/[gem]/[name]/version.rb

Templates 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.

gem bump

Bumps one, several, or all gems in this directory.

Arguments

gem_name - name of the gem (optional, will use the directory name, or all gemspecs if --recurse is given)

Options

-v, --version VERSION            Target version: next [major|minor|patch|pre|release] or a given version number [x.x.x]
-c, --[no-]commit                Create a commit after incrementing gem version (default: true)
-m, --message MESSAGE            Commit message template (default: Bump %{name} to %{version} %{skip_ci})
    --skip-ci                    Add the [skip ci] tag to the commit message
-p, --push                       Push the new commit to the git remote repository
    --remote REMOTE              Git remote to push to (defaults to origin) (default: origin)
-s, --sign                       GPG sign the commit message
    --branch [BRANCH]            Check out a new branch for the target version (e.g. `v1.0.0`)
-t, --tag                        Shortcut for running the `gem tag` command
-r, --release                    Shortcut for the `gem release` command
    --recurse                    Recurse into directories that contain gemspec files
    --file FILE                  Full path to the version file
    --[no-]color
    --pretend

Description

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.rb
  • lib/gem/name/version.rb

gem gemspec

Generates a gemspec.

Arguments

gem_name - name of the gem (optional, will default to the current directory name if not specified)

Options

    --[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
    --pretend

Description

Generates 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 lib

gem release

Releases one or all gems in this directory.

Arguments

gem_name - name of the gem (optional, will use the first gemspec, or all gemspecs if --recurse is given)

Options

    --host HOST                  Push to a compatible host other than rubygems.org
-k, --key KEY                    Use the API key from ~/.gem/credentials
-t, --tag                        Shortcut for running the `gem tag` command
-p, --push                       Push tag to the remote git repository
    --recurse                    Recurse into directories that contain gemspec files
-g, --github                     Create a GitHub release
-d, --description DESCRIPTION    Description of the release
    --repo REPO                  Full name of the repository on GitHub, e.g. svenfuchs/gem-release (defaults to the repo name from the gemspec's homepage if this is a GitHub URL)
    --token TOKEN                GitHub OAuth token
    --[no-]color
    --pretend

Description

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.

gem tag

Tags the HEAD commit with the gem's current version.

Options

-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
    --pretend

Description

Creates 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.

Scenarios

Scenario 1: Single gem in root

Setup

cd /tmp
rm -rf foo
gem bootstrap foo
cd foo
tree -a -I .git

Directory structure

.
├── Gemfile
├── LICENSE.md
├── foo.gemspec
└── lib
    ├── foo
    │   └── version.rb
    └── foo.rb

Behaviour

# this bumps foo
cd /tmp/foo; gem bump

# this also bumps foo
cd /tmp/foo; gem bump foo

Demo

gem-release-scenario-1

Scenario 2: Multiple gems in root

Setup

cd /tmp
rm -rf foo bar
gem bootstrap foo
cd foo
gem bootstrap bar --dir .
tree -a -I .git

Directory structure

.
├── Gemfile
├── LICENSE.md
├── bar.gemspec
├── foo.gemspec
└── lib
    ├── bar
    │   └── version.rb
    ├── bar.rb
    ├── foo
    │   └── version.rb
    └── foo.rb

Behaviour

# 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 bar

Demo

gem-release-scenario-2

Scenario 3: Multiple gems in sub directories

Setup

cd /tmp
rm -rf root
mkdir root
cd root
gem bootstrap foo
gem bootstrap bar
tree -a -I .git

Directory structure

.
├── bar
│   ├── Gemfile
│   ├── LICENSE.md
│   ├── bar.gemspec
│   └── lib
│       ├── bar
│       │   └── version.rb
│       └── bar.rb
└── foo
    ├── Gemfile
    ├── LICENSE.md
    ├── foo.gemspec
    └── lib
        ├── foo
        │   └── version.rb
        └── foo.rb

Behaviour

# 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
cd /tmp/root; gem bump foo

# this bumps bar
cd /tmp/root; gem bump bar

Demo

gem-release-scenario-3

Scenario 4: Nested gem with a conventional sub directory name

Setup

cd /tmp
rm -rf sinja
gem bootstrap sinja
cd sinja
mkdir extensions
cd extensions
gem bootstrap sinja-sequel
cd /tmp/sinja
tree -a -I .git

Directory structure

.
├── Gemfile
├── LICENSE.md
├── extensions
│   └── sinja-sequel
│       ├── Gemfile
│       ├── LICENSE.md
│       ├── lib
│       │   └── sinja
│       │       ├── sequel
│       │       │   └── version.rb
│       │       └── sequel.rb
│       └── sinja-sequel.gemspec
├── lib
│   ├── sinja
│   │   └── version.rb
│   └── sinja.rb
└── sinja.gemspec

Behaviour

# this bumps both sinja and sinja-sequel
cd /tmp/sinja; gem bump --recurse

# this bumps sinja
cd /tmp/sinja; gem bump

# this also bumps sinja
cd /tmp/sinja; gem bump sinja

# this bumps sinja-sequel
cd /tmp/sinja; gem bump sinja-sequel

# this also bumps sinja-sequel
cd /tmp/sinja/extensions/sinja-sequel; gem bump

# this also bumps sinja-sequel
cd /tmp/sinja/extensions/sinja-sequel; gem bump sinja-sequel

Demo

gem-release-scenario-4

Scenario 5: Nested gem with an irregular sub directory name

Setup

cd /tmp
rm -rf sinja
gem bootstrap sinja
cd sinja
mkdir -p extensions
cd extensions
gem bootstrap sinja-sequel
mv sinja-sequel sequel
cd /tmp/sinja
tree -a -I .git

Directory structure

.
├── Gemfile
├── LICENSE.md
├── extensions
│   └── sequel
│       ├── Gemfile
│       ├── LICENSE.md
│       ├── lib
│       │   └── sinja
│       │       ├── sequel
│       │       │   └── version.rb
│       │       └── sequel.rb
│       └── sinja-sequel.gemspec
├── lib
│   ├── sinja
│   │   └── version.rb
│   └── sinja.rb
└── sinja.gemspec

Behaviour

# this bumps both sinja and sinja-sequel
cd /tmp/sinja; gem bump --recurse

# this bumps sinja
cd /tmp/sinja; gem bump

# this also bumps sinja
cd /tmp/sinja; gem bump sinja

# this bumps sinja-sequel only
cd /tmp/sinja; gem bump sinja-sequel

# this also bumps sinja-sequel only
cd /tmp/sinja/extensions/sequel; gem bump

# this also bumps sinja-sequel only
cd /tmp/sinja/extensions/sequel; gem bump sinja-sequel

Demo

gem-release-scenario-5

Development

Running tests:

bundle install
bundle exec rspec

Testing commands against a Geminabox instance:

# start geminabox
bundle install
bundle exec rackup

# workaround rubygems issue with a missing key
# see https://github.com/geminabox/geminabox/issues/153
echo ':localhost: none' >> ~/.gem/credentials

# test release
bundle exec gem release --host=http://localhost:9292 --key localhost

gem-release's People

Contributors

ahangarha avatar aried3r avatar bmaland avatar bond-os avatar cdoughty-r7 avatar charleseff avatar dependabot[bot] avatar dgeb avatar edmellum avatar huerlisi avatar jarl-dk avatar jbodah avatar kennyadsl avatar kubum avatar lanej avatar martikaljuve avatar mcordell avatar michaelglass avatar nono avatar olleolleolle avatar pboling avatar pietia avatar pikachuexe avatar rohith-jayaraman avatar schadenfred avatar shaiguitar avatar svenfuchs avatar tomgi avatar unifiedpost-pullreview avatar zph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gem-release's Issues

Create .gitignore when bootstrapping gem

Since bootstrapping a gem also inits git, I think we should create a default .gitignore file too.

It could contain the following:

*.gem
Gemfile.lock

Any other candidates to exclude?

Also, should Gemfile.lock be removed from gem-release itself? In general, Gemfile.lock files should be excluded from git for gems, but not apps, although I'm not sure how I feel about it here.

@svenfuchs - your thoughts please :)

Get current version of gem or next-version on STDOUT?

Neat gem; I like it a lot.

Is there a way to get the current version without having to grep or sed lib/my_gem/version.rb? I'd like to have a task in a Rakefile to create a git branch with the name of the version, similar to your gem tag command, but I'm having trouble figuring out the right incantations. Alternatively, being able to get the "bumped" new version as just a plain text-string on STDOUT would let me mess with it on my own, like a stripped-down --pretend.

These are probably more enhancement requests than Issues...

Thanks for the good work! :-)

Prompt for confirmation before releasing gems

As discussed in #15, we should add a prompt to gem release (and gem bump --release) for confirmation before pushing both public and private gems.

For instance, Release version 1.0.1 of public_gem to rubygems.org? (y / n) or Release version 1.0.0 of private_gem to http://rubygems.example.com? (y / n). Skip this prompt with the --quiet / -q option.

Does `gem release` support MFA?

Hi, this is probably not problem in gem release, opening anyway as maybe it will help others troubleshooting.

I've tried enabling multi-factor authentication in rubygems.org at "UI and API".
This should make gem push prompt for an OTP code:
https://guides.rubygems.org/using-mfa-in-command-line/
But I didn't use gem push directly, I used gem release which it seems failed, without prompting me for an OTP code. (Sorry, didn't save the output, laptop lost power since).

Is there any known limitation? Are executed commands connected to stdin?

Alternatively, could add an --otp flag to be passed on to gem push, requiring no interaction.

Hmm, possibly my gem CLI was old? I got via rbenv install 2.5.6; gem --version says 2.7.6.2, and it doesn't support --otp, so I guess doesn't know how to prompt either.
Building ruby 2.6.4 gave me gem 3.0.3 which does support --otp so I guess could Just Work? I'll confirm next time I make a release...

P.S. another workaround: gem release worked when I set my account MFA to "UI only" level. This is weaker but better than nothing.

[additional search keywords: 2FA, OTP]

gem bump --tag --release pushes the wrong version

I don't know how this happened, but gem release 0.6.0 has started pushing the wrong versions of my gems to rubygems.org. Here is one example

∴ gem bump --tag --release
Bumping flag_shih_tzu from 0.3.9 to version 0.3.10
Creating commit
[master f673691] Bump to 0.3.10
 1 file changed, 1 insertion(+), 1 deletion(-)
Pushing to the origin git repository
Counting objects: 9, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 501 bytes | 0 bytes/s, done.
Total 5 (delta 1), reused 0 (delta 0)
To https://github.com/pboling/flag_shih_tzu.git
   4f60d20..f673691  master -> master
  Successfully built RubyGem
  Name: flag_shih_tzu
  Version: 0.3.9
  File: flag_shih_tzu-0.3.9.gem
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please use `gem yank` to remove bad gem releases.

Running straight gem release works:

∴ gem release
  Successfully built RubyGem
  Name: flag_shih_tzu
  Version: 0.3.10
  File: flag_shih_tzu-0.3.10.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: flag_shih_tzu (0.3.10)
Deleting left over gem file flag_shih_tzu-0.3.10.gem
All is good, thanks my friend.

When command are combined, the .gemrelease file is ignored

When a .gemrelease file is created with, for example, a host for release:


---
release:
  host: 'http://foo.bar'

The file is picked up when issueing gem release but the file is ignored when combining the release command with another command gem bump --version 1.1.3 --release

Create scaffolding by default with "gem bootstrap"

Without the --scaffold option, gem bootstrap is pretty much redundant with gem gemspec. Why not make --scaffold the default?

I think it's much easier to remember and use this:

gem bootstrap new_gem

than this:

gem bootstrap new_gem --scaffold

And I imagine this is one of the most common use cases for gem-release.

`gem bump` work with "*_rb" suffix

We've been writing some gems that need to have "*_rb" at the end for the gem name

Ex.

# gem name is task_rb
lib/task/version.rb

It would be great if gem bump worked on this as well

Feature: --date to bump the datestamp in the gemspec when bumping

Feature Suggestion: --date to bump the datestamp in the gemspec when bumping

This would really complete the transition from Jeweler for me. I find I forget to bump the date alot. Apparently rubygems.org uses the date from the gemspec, and not the date you push a gem. I have a bunch of consecutive releases all appearing as on the same day on rubygems, which makes it look like my code was buggy, when really I just forgot to manually bump the date.

already initialized constant warning when bumping

DB:~/ruby $ bundle gem test
      create  test/Gemfile
      create  test/Rakefile
      create  test/.gitignore
      create  test/test.gemspec
      create  test/lib/test.rb
      create  test/lib/test/version.rb
Initializating git repo in /Users/denis/ruby/test
DB:~/ruby $ cd test
DB:~/ruby/test $ ls
Gemfile      Rakefile     lib          test.gemspec
DB:~/ruby/test $ gem bump
Bumping from 0.0.1 to version 0.0.2
Creating commit
/Users/denis/ruby/test/lib/test/version.rb:2: warning: already initialized constant VERSION

This is using gem 1.8.5, gem-release 0.0.16, bundler 1.0.15 and ruby 1.9.2p180. I looked around in the code.

`gem bootstrap --private` for gems that are private

I've been using bundler for bootstrapping my gems (bundle gem my_gem), but it hasn't been quite enough control for me. I feel like gem-release solves a lot of the issues I have with bundler in particular with give me the gem bump command which is awesome.

One of the things I really love about bundler is that is makes gems private by default. Most of the work I do is propietary, so I don't want to accidentally push a new gem to RubyGems. It would be great if gem-release had an option for this when bootstrapping a project.

This is how bundler solves the RubyGems push issue: https://github.com/bundler/bundler/blob/master/lib/bundler/templates/newgem/newgem.gemspec.tt#L19

bump fails when there is a space in the path to project

My project dir is inside "/Users/seanmackesey/Google Drive/code/lib/ruby". When I run gem bump, I get

fatal: '/Users/seanmackesey/Google' is outside repository
The task bump could not be completed. Subsequent tasks will not be attempted.

Looks like an issue with that space.

`gem bump --help` returns the options for `gem` but the summary for `gem bump`

$ gem bump --help
Usage: gem [options]

  Options:
    -v, --version VERSION            Target version: next [major|minor|patch|pre|release] or a given version number [x.x.x] (not set by default)
    -c, --[no-]commit                Perform a commit after incrementing gem version (defaults to true)
    -p, --[no-]push                  Push to the git destination (defaults to false)
    -d, --destination DESTINATION    destination git repository (defaults to origin)
    -t, --[no-]tag                   Create a git tag and push it to the git destination (defaults to false)
    -r, --[no-]release               Build gem from a gemspec and push to rubygems.org (defaults to false)
    -k, --key KEY                    When releasing: use the given API key from ~/.gem/credentials (not set by default)
        --host HOST                  When releasing: push to a gemcutter-compatible host other than rubygems.org (not set by default)


  Common Options:
    -h, --help                       Get help on this command
    -V, --[no-]verbose               Set the verbose level of output
    -q, --quiet                      Silence commands
        --config-file FILE           Use this config file instead of default
        --backtrace                  Show stack backtrace on errors
        --debug                      Turn on Ruby debugging


  Summary:
    Bump the gem version

.gemrelease doesn't work with key and host

running gem build followed by gem push --key foo --host http://foo.host/private works.

However with a .gemrelease

release:
  key: foo
  host: http://foo.host/private

Running gem release fails, with a 401 from my gem server:

...
Pushing gem to http://foo.host/private...
Authorization key is invalid
...
Tasks: TOP => release => release:rubygem_push

Are host and key not designed to work in this manner? Documentation leads me to believe they are.

gem bump not working in combination with release or tag

When combining bump with the tag or release options, the tag and release commands attempt to work with the prior version number. Oddly, the tests cover these scenarios and pass without a problem, so there must be an issue within the tests as well.

I suspect that the gemspec file isn't truly being reloaded when invoking release and/or tag, but I haven't yet found why. I'll continue to look into this, unless you see something obvious, @svenfuchs.

By the way, issuing a "gem bump" followed by "gem release" or "gem tag" works just as expected.

Integrate with Rake Tasks

It would be nice if one could integrate this gem with Rake Tasks that incorporates options.
My current workaround:

desc 'Bumps and pushes new minor version.'
task :bump_minor do
  puts 'Bumping minor.'
  cmd = 'gem bump --version minor --tag --push'
  raise 'Error bumping minor version!' unless system(cmd)
end

desc 'Bumps and pushes new major version.'
task :bump_major do
  puts 'Bumping major.'
  cmd = 'gem bump --version major --tag --push'
  raise 'Error bumping major version!' unless system(cmd)
end

desc 'Bumps and pushes new patch version.'
task :bump_patch do
  puts 'Bumping patch.'
  cmd = 'gem bump --version patch --tag --push'
  raise 'Error bumping patch version!' unless system(cmd)
end

gem-release load error on lower ruby version like 2.2.4

After installing gem-release version 2.0.1, I found that all my gem commands print error message like this:

Error loading RubyGems plugin "~/.rvm/gems/ruby-2.2.4/gems/gem-release-2.0.1/lib/rubygems_plugin.rb": ~/.rvm/gems/ruby-2.2.4/gems/gem-release-2.0.1/lib/gem/release/cmds/release.rb:12: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
...e given gemspec(s), pushes them to rubygems.org

Then I check the source code of the gem-release, seems like multi-line string syntax like <<~str is not supported on ruby 2.2.4 or lower, syntax like <<-str works just fine.

I think it will be better if you can specific the ruby version gem-release supports in the gemspec or change all the <<~str to <<-str.split("\n").map(&:lstrip).join("\n")? Now I change my local gem-release code to make it work~

THX

release and tag options removed from bump command

While attempting to extend the bump command, I encountered a nasty problem for gem-release in Ruby 1.9.x that doesn't occur in 1.8.7, REE, or jRuby. When bumping and releasing or tagging a gem at the same time (e.g gem bump -t -r), the old version number, instead of the new bumped version number, gets tagged and released. Luckily, this tends to fail, since duplicate versions can't be tagged in git or pushed up to rubygems.org.

I've created a new bump_tag_and_release branch that now illustrates the problem with a test.

Because of this bug, I've removed these options from bump and pushed out a new version of gem-release: 0.2.0.

The problem seems to be that the version loaded by Gem::Specification.load() is not getting reloaded by TagCommand and ReleaseCommand for 1.9+.

One question is whether we really want to continue to support the release and tag options for bump. This is not in my own workflow, which tends to be a separate gem bump -p followed by a gem release -t. Upon adding key and host options to bump, it was beginning to look like an alpabet soup of options - perhaps too many to use reliably.

Does anyone feel strongly about keeping release and tag in bump?

@svenfuchs - thoughts? by the way, the only reason this project is failing in travis is because of the new branch; master is fine.

performing actions on branch was unexpected

I was on a branch locally when i ran gem bump --tag --release --version minor and it performed all the actions while still on that branch instead of on the master branch. I'm sure it's my fault, but it was kind of a foot gun and I thought i'd mention it since there may be something that could be done, like having an option in the config that allows you to specify which branch to perform the actions on.

gem bump tags the wrong version

Hi, I'm trying to use the gem like this: gem bump --tag --skip-ci --push --version patch
my current version is 0.0.1 and I'm bumping to 0.1.0
I'm expecting the tag to be set to 'v0.1.0' but instead I'm getting this output (and the tag created is the same):

bump my-gem 0.0.1 0.1.0
version lib/my-gem/version.rb 0.0.1 0.1.0
git_add lib/my-gem/version.rb
git_commit "Bump my-gem to 0.1.0 [skip ci]"
[master 128a501] Bump my-gem to 0.1.0 [skip ci]
 1 file changed, 1 insertion(+), 1 deletion(-)
git_push origin
tag my-gem 0.0.1
git_tag v0.0.1 v0.0.1
git_push origin

Publish gem after was once revoked, and publishes, but returns error

Gem is published. Server still sends back an error mesage.

This is for a very active gem, https://github.com/shakacode/react_on_rails

Using this repo: https://github.com/svenfuchs/gem-release

and this script:

https://github.com/shakacode/react_on_rails/blob/master/rakelib/release.rake#L64

+ [email protected]
No distRepo provided, done.
cd /Users/justin/shakacode/react-on-rails/react_on_rails && gem release
WARNING:  open-ended dependency on connection_pool (>= 0) is not recommended
  if connection_pool is semantically versioned, use:
    add_runtime_dependency 'connection_pool', '~> 0'
WARNING:  open-ended dependency on rails (>= 3.2) is not recommended
  if rails is semantically versioned, use:
    add_runtime_dependency 'rails', '~> 3.2'
WARNING:  open-ended dependency on addressable (>= 0) is not recommended
  if addressable is semantically versioned, use:
    add_runtime_dependency 'addressable', '~> 0'
WARNING:  open-ended dependency on rspec (>= 0, development) is not recommended
  if rspec is semantically versioned, use:
    add_development_dependency 'rspec', '~> 0'
WARNING:  open-ended dependency on coveralls (>= 0, development) is not recommended
  if coveralls is semantically versioned, use:
    add_development_dependency 'coveralls', '~> 0'
WARNING:  open-ended dependency on generator_spec (>= 0, development) is not recommended
  if generator_spec is semantically versioned, use:
    add_development_dependency 'generator_spec', '~> 0'
WARNING:  open-ended dependency on pry (>= 0, development) is not recommended
  if pry is semantically versioned, use:
    add_development_dependency 'pry', '~> 0'
WARNING:  open-ended dependency on pry-byebug (>= 0, development) is not recommended
  if pry-byebug is semantically versioned, use:
    add_development_dependency 'pry-byebug', '~> 0'
WARNING:  open-ended dependency on pry-stack_explorer (>= 0, development) is not recommended
  if pry-stack_explorer is semantically versioned, use:
    add_development_dependency 'pry-stack_explorer', '~> 0'
WARNING:  open-ended dependency on pry-doc (>= 0, development) is not recommended
  if pry-doc is semantically versioned, use:
    add_development_dependency 'pry-doc', '~> 0'
WARNING:  open-ended dependency on pry-state (>= 0, development) is not recommended
  if pry-state is semantically versioned, use:
    add_development_dependency 'pry-state', '~> 0'
WARNING:  open-ended dependency on pry-toys (>= 0, development) is not recommended
  if pry-toys is semantically versioned, use:
    add_development_dependency 'pry-toys', '~> 0'
WARNING:  open-ended dependency on pry-rescue (>= 0, development) is not recommended
  if pry-rescue is semantically versioned, use:
    add_development_dependency 'pry-rescue', '~> 0'
WARNING:  open-ended dependency on binding_of_caller (>= 0, development) is not recommended
  if binding_of_caller is semantically versioned, use:
    add_development_dependency 'binding_of_caller', '~> 0'
WARNING:  open-ended dependency on awesome_print (>= 0, development) is not recommended
  if awesome_print is semantically versioned, use:
    add_development_dependency 'awesome_print', '~> 0'
WARNING:  open-ended dependency on gem-release (>= 0, development) is not recommended
  if gem-release is semantically versioned, use:
    add_development_dependency 'gem-release', '~> 0'
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
  Successfully built RubyGem
  Name: react_on_rails
  Version: 6.8.2
  File: react_on_rails-6.8.2.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: react_on_rails (6.8.2)
Deleting left over gem file react_on_rails-6.8.2.gem
WARNING:  open-ended dependency on connection_pool (>= 0) is not recommended
  if connection_pool is semantically versioned, use:
    add_runtime_dependency 'connection_pool', '~> 0'
WARNING:  open-ended dependency on rails (>= 3.2) is not recommended
  if rails is semantically versioned, use:
    add_runtime_dependency 'rails', '~> 3.2'
WARNING:  open-ended dependency on addressable (>= 0) is not recommended
  if addressable is semantically versioned, use:
    add_runtime_dependency 'addressable', '~> 0'
WARNING:  open-ended dependency on rspec (>= 0, development) is not recommended
  if rspec is semantically versioned, use:
    add_development_dependency 'rspec', '~> 0'
WARNING:  open-ended dependency on coveralls (>= 0, development) is not recommended
  if coveralls is semantically versioned, use:
    add_development_dependency 'coveralls', '~> 0'
WARNING:  open-ended dependency on generator_spec (>= 0, development) is not recommended
  if generator_spec is semantically versioned, use:
    add_development_dependency 'generator_spec', '~> 0'
WARNING:  open-ended dependency on pry (>= 0, development) is not recommended
  if pry is semantically versioned, use:
    add_development_dependency 'pry', '~> 0'
WARNING:  open-ended dependency on pry-byebug (>= 0, development) is not recommended
  if pry-byebug is semantically versioned, use:
    add_development_dependency 'pry-byebug', '~> 0'
WARNING:  open-ended dependency on pry-stack_explorer (>= 0, development) is not recommended
  if pry-stack_explorer is semantically versioned, use:
    add_development_dependency 'pry-stack_explorer', '~> 0'
WARNING:  open-ended dependency on pry-doc (>= 0, development) is not recommended
  if pry-doc is semantically versioned, use:
    add_development_dependency 'pry-doc', '~> 0'
WARNING:  open-ended dependency on pry-state (>= 0, development) is not recommended
  if pry-state is semantically versioned, use:
    add_development_dependency 'pry-state', '~> 0'
WARNING:  open-ended dependency on pry-toys (>= 0, development) is not recommended
  if pry-toys is semantically versioned, use:
    add_development_dependency 'pry-toys', '~> 0'
WARNING:  open-ended dependency on pry-rescue (>= 0, development) is not recommended
  if pry-rescue is semantically versioned, use:
    add_development_dependency 'pry-rescue', '~> 0'
WARNING:  open-ended dependency on binding_of_caller (>= 0, development) is not recommended
  if binding_of_caller is semantically versioned, use:
    add_development_dependency 'binding_of_caller', '~> 0'
WARNING:  open-ended dependency on awesome_print (>= 0, development) is not recommended
  if awesome_print is semantically versioned, use:
    add_development_dependency 'awesome_print', '~> 0'
WARNING:  open-ended dependency on gem-release (>= 0, development) is not recommended
  if gem-release is semantically versioned, use:
    add_development_dependency 'gem-release', '~> 0'
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
  Successfully built RubyGem
  Name: react_on_rails
  Version: 6.8.2
  File: react_on_rails-6.8.2.gem
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please use `gem yank` to remove bad gem releases.
rake aborted!
Command failed with status (1): [cd /Users/justin/shakacode/react-on-rails/...]
/Users/justin/shakacode/react-on-rails/react_on_rails/rakelib/task_helpers.rb:20:in `block in sh_in_dir'
/Users/justin/shakacode/react-on-rails/react_on_rails/rakelib/task_helpers.rb:20:in `each'
/Users/justin/shakacode/react-on-rails/react_on_rails/rakelib/task_helpers.rb:20:in `sh_in_dir'
/Users/justin/shakacode/react-on-rails/react_on_rails/rakelib/release.rake:64:in `block in <top (required)>'
/Users/justin/.rvm/gems/ruby-2.3.1@react_on_rails/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => release
(See full trace by running task with --trace)

See #1589 and Issue on RubyGems.

Cannot bump -v patch if current version has only 2 characters

Small issue with bumping existing gems.

Steps to reproduce:
Create a gem with version number 2.0
Bump with gem bump -v patch

Error message:

ERROR:  While executing gem ... (NoMethodError)
    undefined method `compact' for nil:NilClass

It took me a while to figure out where the error popped up.
The problem is that the target is not being set correctly in Gem::Release::Version::Number

Issues with in-repo gems

I have a RubyGem with another RubyGem in-repo (directly, not a submodule). The file structure looks something like:

  • sinja/
    • .git/
    • Gemfile
    • lib/sinja/version.rb
    • sinja.gemspec
    • extensions/sequel/
      • Gemfile
      • lib/sinja/sequel/version.rb
      • sinja-sequel.gemspec

The gemspecs look normal, i.e. like they would if they were in separate repos. In the two Gemfiles, after the gemspec directive, I'm using the :path option to point to the relative directories for development. So something like:

# sinja/Gemfile
gemspec
gem 'sinja-sequel', :require=>false, :path=>'extensions/sequel'
# sinja/sinja.gemspec
spec.add_development_dependency 'sinja-sequel', '~> 0.1'
# sinja/extensions/sequel/Gemfile
gemspec
gem 'sinja', :require=>false, :path=>'../..' 
# sinja/extensions/sequel/sinja-sequel.gemspec
spec.add_dependency 'sinja', '>= 1.2.0.pre2', '< 2'

Here's the scoop:

  • bundle install|update|exec works fine in both gemspec directories
  • gem build|push works fine in both gemspec directories
  • gem bump finds sinja/extensions/sequel/lib/sinja/sequel/version.rb first and uses it as the base version for both gems, updating both version.rb files to the new version (PROBLEM 1)
  • gem release works fine in sinja/extensions/sequel/
  • gem release in sinja/ finds sinja/extensions/sequel/sinja-sequel.gemspec first and tries to re-release it (PROBLEM 2)
  • gem release sinja.gemspec emits ERROR: Gemspec file not found: sinja.gemspec (PROBLEM 3)

PROBLEM 1: How can I restrict gem bump to only work on one or the other version.rb file at a time?

PROBLEM 2: Why doesn't gem release in the top-level directory find the top-level gemspec?

PROBLEM 3: What in the blazes is going on here?

Make --quiet a global flag / flag supported by all commands

Hi,

it would be nice to have the --quiet flag for all subcommands. I currently use gem bump in a filter script for git-flow and it is a real pain to catch all output by gem bump to make sure that the filter just returns the version to use for the release.

Question: it there a way bump version in changelog file?

Hello.

First of all, thanks for making this gem. I was very glad when I have found it. :)

I have a question.
I want to use this gem and everything is fine. But in addition to existing functionality I also would to bump version in my changelog file.

E.g.

before

--- CHANGELOG.md	2019-10-11 13:00:11.095262564 +0300
+++ CHANGELOG.md	2019-10-11 13:00:12.455265870 +0300
@@ -1 +1,3 @@
 ## Unreleased
+
+## 0.3.1 - 2019-09-09

 Bugfixes:
  - fix 1 ...
  - fix 2

 ## 0.3.0 - 2019-09-01

Is there any way to do this? May be some way to hook into bump command somewhere between actual changing of version.rb file and making a commit.

For now I use a workaround... I write simple script which invokes gem bump --no-commit --branch, then I make changes in CHANGELOG.md and then I invoke git add and git push myself.

I will be glad to hear your thoughts.

Automatic changelog?

I've been using this gem for a number of projects and really appreciate the work that has gone into it. ❤️

When generating a release, I wonder if it would be possible to also update the changelog listed in the gemspec since the last tag. Maybe in an interactive fashion, allowing the user to select, comment, and link to the commits?

I'd be willing to put some effort into this if the idea aligns with the project.

HTTP Basic: Access Denied

Hey, I assume this more an error on my part, but I see the following output while running gem release

Enter your RubyGems.org credentials.
Don't have an account yet? Create one at http://rubygems.org/sign_up
Email:   
Password:   
Pushing gem to https://rubygems.org...
HTTP Basic: Access denied.

I have setup my credentials for rubygems in ~/.gem/credentials and am using the correct values when running gem release.

Any ideas?

Cheers!

Match rubygems not-quite-Semver versioning for pre-release versioning

Unfortunately, rubygems requires a . separator instead of a - for pre-release gems. Would it be possible to update gem-release to comply with that constraint?

Ex. "0.169.0" should gem bump -v pre to "0.170.0.pre.1" instead of "0.170.0-pre.1"

See rubygems/rubygems#592 (comment) and the offending line that causes all the issues: https://github.com/rubygems/rubygems/blob/064cfaf7f5357c16a4fae04d53587fcf69b6df3f/lib/rubygems/version.rb#L219

Incorrect determination of path to version.rb

/tmp $ bundle gem foo-bar
      create  foo-bar/Gemfile
      create  foo-bar/Rakefile
      create  foo-bar/.gitignore
      create  foo-bar/foo-bar.gemspec
      create  foo-bar/lib/foo-bar.rb
      create  foo-bar/lib/foo-bar/version.rb
Initializating git repo in /private/tmp/foo-bar
/tmp $ cd foo-bar/
/tmp/foo-bar $ gem bump --version patch
Ignoring foo-bar. Version file /private/tmp/foo-bar/lib/foo_bar/version.rb not found
No version files could be found, so no actions were performed.

consider including a `git push` when tagging

Currently, gem-release performs git push --tags when tagging a release. If there are any commits outstanding, as there often are when bumping a version, it's necessary to perform a separate git push to get the working branch sync'd with origin.

Should we combine these commands in TagCommand ?

    def push
      say "Pushing to origin git repository" unless quiet?
      `git push origin`

      say "Pushing --tags to origin git repository" unless quiet?
      `git push --tags origin`
    end

I've always been confused as to why git forces these steps to be separate, so perhaps I'm missing something. Either way, it would be good to understand the rationale.

Allow for optional yaml configuration file

As discussed in #15, gem-release should allow for an entirely optional yaml configuration file named .gemrelease. This file could mirror the command / options available for gem-release. For instance:

release:
  host: http://rubygems.example.com
  key: keyname

It could also be used to disable commands:

release: disabled

This would be useful for private gems that are built from source by bundler and never pushed to a host (e.g. gem 'private_gem', :git => '[email protected]:example/private_gem.git').

Unable to provide credentials when publishing to Rubygems

When running gem release and entering credentials, I'm unable to submit my email and continue the process.

Screen Shot 2019-10-25 at 12 10 48 PM

Expected: Hitting "Enter" submits my email and prompts for my password.
Actual: Hitting "Enter" injects "^M" instead of prompting for a password.

picks wrong version with --pretend?

$ gem bump -v patch --tag --push --pretend

Bumping travis-conditions from version 1.0.0-dev.2 to 1.0.0
Staging lib/travis/conditions/version.rb
$ git add lib/travis/conditions/version.rb

Creating commit
$ git commit -m "Bump travis-conditions to 1.0.0"

Pushing to the origin git repository
$ git push origin

Tagging travis-conditions as version 1.0.0.pre.dev.2
Creating git tag v1.0.0.pre.dev.2
$ git tag -am "tag v1.0.0.pre.dev.2" v1.0.0.pre.dev.2

Pushing tags to the origin git repository
$ git push --tags origin

All is good, thanks my friend.

Cannot execute `gem bump` within a rake task now

This used to work.

I'd love some help to debug this.

Script with pointer to failing line: https://github.com/shakacode/react_on_rails/blob/master/rakelib/release.rake#L51

rake release[3.0.3,false,false]                                                                                                                                                                                                                                                                                      

rm -rf /Users/justin/shakacode/react_on_rails/gen-examples/examples
cd /Users/justin/shakacode/react_on_rails && gem bump --no-commit --version 3.0.3
ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command bump
rake aborted!
Command failed with status (1): [cd /Users/justin/shakacode/react_on_rails ...]
/Users/justin/shakacode/react_on_rails/rakelib/task_helpers.rb:20:in `block in sh_in_dir'
/Users/justin/shakacode/react_on_rails/rakelib/task_helpers.rb:20:in `each'
/Users/justin/shakacode/react_on_rails/rakelib/task_helpers.rb:20:in `sh_in_dir'
/Users/justin/shakacode/react_on_rails/rakelib/release.rake:51:in `block in <top (required)>'
/Users/justin/.rvm/gems/ruby-2.2.4@react_on_rails/bin/ruby_executable_hooks:15:in `eval'
/Users/justin/.rvm/gems/ruby-2.2.4@react_on_rails/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => release
(See full trace by running task with --trace)

[REQ] When given a name, use that instead of the current directory

A bit of unexpected behaviour. Perhaps it should be documented in the README or the help output, perhaps?

I expect that if I pass a name to gem bootstrap, it would use that name, create the directory and then do it's jazz. Instead it uses the current directory for the name. Whoops!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.