Skip to content

Commit

Permalink
Add create_release task
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzy committed Jan 30, 2014
1 parent 4e3ce17 commit 8cfa010
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "bundler/gem_tasks"
require "bundler/gem_helper"
require 'rspec/core/rake_task'

task :spec => 'spec:all'
Expand Down Expand Up @@ -28,3 +29,40 @@ namespace :spec do
end
end

desc 'Release gem and create a release on GitHub'
task 'create_release' => 'release' do
require 'octokit'

Octokit.configure do |c|
c.login = `git config --get github.user`.strip
c.access_token = `git config --get github.token`.strip
end

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

0 comments on commit 8cfa010

Please sign in to comment.