Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (28 sloc) 1.09 KB
#!/usr/bin/env ruby
# frozen_string_literal: true
# git-gem-release-tag: Create a git tag for a Ruby namespace's version,
# build a new gem for that tag, and push that gem to Rubygems.
def act(s)
if ARGV.include? "--dry-run"
puts s
else
system s
end
end
gemspec_candidates = Dir[File.join(`pwd`.chomp, "*.gemspec")]
abort("No gemspec found.") if gemspec_candidates.empty?
abort("You have more than one gemspec, giving up.") if gemspec_candidates.size > 1
gemspec = gemspec_candidates.first
act "gem build #{gemspec}"
gemfile_candidates = Dir[File.join(`pwd`.chomp, "*.gem")]
abort("No gemfile found, did `gem build` fail?") if gemfile_candidates.empty?
abort("More than one gemfile found, try running with them removed.") if gemfile_candidates.size > 1
gemfile = File.basename gemfile_candidates.first
/-(?<version>[^-]+)\.gem$/ =~ gemfile
tags = `git tag`.split
abort("Did you forget to bump your version?") if tags.include?(version)
# you'd better hope each of these steps works!
act "git tag #{version}"
act "git push origin #{version}"
act "gem push #{gemfile}"
act "rm -f #{gemfile}"