Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #5414 - bundler:seg-patch-release-milestone, r=segiddins
Browse files Browse the repository at this point in the history
[Release] Pull PRs to backport from GH milestone
  • Loading branch information
bundlerbot committed Feb 9, 2017
2 parents 74341aa + 03c8f40 commit cfd66c9
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions task/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ namespace :release do
abort
end

desc "Make a patch release with the specified PRs from master"
def gh_api_request(opts)
require "net/http"
require "json"
host = opts.fetch(:host) { "https://api.github.com/" }
path = opts.fetch(:path)
response = Net::HTTP.get(URI.join(host, path))
JSON.parse(response)
end

desc "Make a patch release with the PRs from master in the patch milestone"
task :patch, :version do |_t, args|
version = args.version
prs = args.extras

version ||= begin
version = BUNDLER_SPEC.version
Expand All @@ -28,6 +36,18 @@ namespace :release do

confirm "You are about to release #{version}, currently #{BUNDLER_SPEC.version}"

milestones = gh_api_request(:path => "repos/bundler/bundler/milestones?state=open")
unless patch_milestone = milestones.find {|m| m["title"] == version }
abort "failed to find #{version} milestone on GitHub"
end
prs = gh_api_request(:path => "repos/bundler/bundler/pulls?milestone=#{patch_milestone["number"]}")
prs.map! do |pr|
unless pr["merged_at"]
abort "https://github.com/bundler/bundler/pull/#{pr["number"]} hasn't been merged yet!"
end
pr["number"]
end

version_file = "lib/bundler/version.rb"
version_contents = File.read(version_file)
unless version_contents.sub!(/^(\s*VERSION = )"#{Gem::Version::VERSION_PATTERN}"/, "\\1#{version.to_s.dump}")
Expand Down

0 comments on commit cfd66c9

Please sign in to comment.