Skip to content

Instantly share code, notes, and snippets.

@mizzy
Last active August 29, 2015 13:55
Show Gist options
  • Save mizzy/8703797 to your computer and use it in GitHub Desktop.
Save mizzy/8703797 to your computer and use it in GitHub Desktop.
require "bundler/gem_tasks"
require "bundler/gem_helper"
require 'rspec/core/rake_task'
require 'octokit'
Octokit.configure do |c|
c.login = `git config --get github.user`.strip
c.access_token = `git config --get github.token`.strip
end
desc 'Release gem and create a release on GitHub'
task 'create_release' => 'release' do
t = Bundler::GemHelper.new
current_version = "v#{t.gemspec.version.to_s}"
previous_version = ""
`git tag`.split(/\n/).each do |tag|
break if tag == current_version
previous_version = tag
end
log = `git log #{previous_version}..#{current_version} --grep=Merge`
repo = `git remote -v | grep origin`.match(/([\w-]+\/[\w-]+)\.git/)[1]
description = []
log.split(/commit/).each do |lines|
lines.match(/Merge pull request \#(\d+)/) do |m|
url = "https://github.com/#{repo}/pull/#{m[1]}"
title = Octokit.pull_request(repo, m[1]).title
description << "* [#{title}](#{url})"
end
end
Octokit.create_release(
repo,
current_version,
body: description.join("\n"),
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment