2023-02-09 12:52:51 +03:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2023-02-10 02:42:42 +03:00
|
|
|
if ARGV.size < 2
|
|
|
|
puts "Usage: #{$0} <from version tag> <to version tag> [--no-dry-run]"
|
|
|
|
puts " : if --no-dry-run is specified, it will create a release on GitHub"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2023-02-09 12:52:51 +03:00
|
|
|
require "bundler/inline"
|
|
|
|
|
|
|
|
gemfile do
|
|
|
|
source "https://rubygems.org"
|
|
|
|
gem "octokit"
|
|
|
|
gem "faraday-retry"
|
|
|
|
gem "nokogiri"
|
|
|
|
end
|
|
|
|
|
|
|
|
require "open-uri"
|
|
|
|
|
|
|
|
Octokit.configure do |c|
|
|
|
|
c.access_token = ENV['GITHUB_TOKEN']
|
|
|
|
c.auto_paginate = true
|
|
|
|
c.per_page = 100
|
|
|
|
end
|
|
|
|
|
|
|
|
client = Octokit::Client.new
|
|
|
|
|
2023-02-10 02:42:42 +03:00
|
|
|
note = "## What's Changed\n\n"
|
|
|
|
|
2024-01-09 08:53:17 +03:00
|
|
|
notes = []
|
|
|
|
|
2023-02-09 12:52:51 +03:00
|
|
|
diff = client.compare("ruby/ruby", ARGV[0], ARGV[1])
|
|
|
|
diff[:commits].each do |c|
|
2024-01-04 11:53:32 +03:00
|
|
|
if c[:commit][:message] =~ /\[(Backport|Feature|Bug) #(\d*)\]/
|
|
|
|
url = "https://bugs.ruby-lang.org/issues/#{$2}"
|
2023-02-09 12:52:51 +03:00
|
|
|
title = Nokogiri::HTML(URI.open(url)).title
|
|
|
|
title.gsub!(/ - Ruby master - Ruby Issue Tracking System/, "")
|
2023-02-09 13:21:05 +03:00
|
|
|
elsif c[:commit][:message] =~ /\(#(\d*)\)/
|
2023-02-09 12:52:51 +03:00
|
|
|
url = "https://github.com/ruby/ruby/pull/#{$1}"
|
|
|
|
title = Nokogiri::HTML(URI.open(url)).title
|
|
|
|
title.gsub!(/ · ruby\/ruby · GitHub/, "")
|
2023-02-09 13:21:05 +03:00
|
|
|
else
|
|
|
|
next
|
2023-02-09 12:52:51 +03:00
|
|
|
end
|
2024-01-09 08:53:17 +03:00
|
|
|
notes << "* [#{title}](#{url})"
|
2023-02-09 13:21:05 +03:00
|
|
|
rescue OpenURI::HTTPError
|
|
|
|
puts "Error: #{url}"
|
2023-02-09 12:52:51 +03:00
|
|
|
end
|
|
|
|
|
2024-01-09 08:53:17 +03:00
|
|
|
notes.uniq!
|
|
|
|
|
|
|
|
note << notes.join("\n")
|
|
|
|
|
2024-01-10 07:41:54 +03:00
|
|
|
note << "\n\n"
|
2023-02-10 02:42:42 +03:00
|
|
|
note << "Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.\n\n"
|
|
|
|
note << "## Full Changelog\n\n"
|
|
|
|
note << "https://github.com/ruby/ruby/compare/#{ARGV[0]}...#{ARGV[1]}\n\n"
|
|
|
|
|
|
|
|
if ARGV[2] == "--no-dry-run"
|
2024-01-12 08:55:57 +03:00
|
|
|
name = ARGV[1].gsub(/^v/, "").gsub(/_/, ".")
|
2024-01-12 09:26:50 +03:00
|
|
|
prerelease = ARGV[1].match?(/rc|preview/) ? true : false
|
|
|
|
client.create_release("ruby/ruby", ARGV[1], name: name, body: note, make_latest: "false", prerelease: prerelease)
|
2023-02-10 02:42:42 +03:00
|
|
|
puts "Created a release: https://github.com/ruby/ruby/releases/tag/#{ARGV[1]}"
|
|
|
|
else
|
|
|
|
puts note
|
|
|
|
end
|