diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-02-09 18:52:51 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-02-09 18:52:59 +0900 |
commit | 5991af204c2b27d7d5343177e6ad247d5954a6c0 (patch) | |
tree | af328c71605156927058d45c0a2d22e5a8c074dd | |
parent | 728d2f808e7baf92d9190b3b27161d2405236eb0 (diff) | |
download | ruby-5991af204c2b27d7d5343177e6ad247d5954a6c0.tar.gz |
Added helper script for generate github releases
-rwxr-xr-x | tool/gen-github-release.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tool/gen-github-release.rb b/tool/gen-github-release.rb new file mode 100755 index 0000000000..bd0753afb2 --- /dev/null +++ b/tool/gen-github-release.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby + +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 + +diff = client.compare("ruby/ruby", ARGV[0], ARGV[1]) +diff[:commits].each do |c| + if c[:commit][:message] =~ /\[Backport #(\d*)\]/ + url = "https://bugs.ruby-lang.org/issues/#{$1}" + title = Nokogiri::HTML(URI.open(url)).title + title.gsub!(/ - Ruby master - Ruby Issue Tracking System/, "") + end + + if c[:commit][:message] =~ /\(#(\d*)\)/ + url = "https://github.com/ruby/ruby/pull/#{$1}" + title = Nokogiri::HTML(URI.open(url)).title + title.gsub!(/ · ruby\/ruby · GitHub/, "") + end + + next unless url && title + + puts "* [#{title}](#{url})" +end + |