Skip to content

Instantly share code, notes, and snippets.

@johnholdun
Last active August 29, 2015 14:26
Show Gist options
  • Save johnholdun/9e87941aa20bf5a90910 to your computer and use it in GitHub Desktop.
Save johnholdun/9e87941aa20bf5a90910 to your computer and use it in GitHub Desktop.
commit, build, and publish a new version of your gem
namespace :gem do
task publish: [:commit, :build, :fury]
task :commit do
current_branch = %x(git rev-parse --abbrev-ref HEAD).strip
git_status = %x(git status --short --untracked-files=no)
unless current_branch == 'master'
puts 'Only run this task with master checked out!'
return
end
if git_status.lines.any? { |f| f =~ /^\s+A/ }
puts 'You have staged changes! Please unstage them before proceeding.'
return
end
puts "Committing version #{MyProject::VERSION}..."
%x(
git add lib/my_project/version.rb
git commit -m "Version #{MyProject::VERSION}"
git push origin master
)
end
task :build do
puts %x(bundle exec gem build my_project.gemspec)
end
task :fury do
puts %x(fury push my_project-#{MyProject::VERSION}.gem)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment