Last active
August 29, 2015 13:55
-
-
Save mizzy/8703797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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