Skip to content

Commit

Permalink
Enhancement github releases generator
Browse files Browse the repository at this point in the history
  * Create GitHub Releases by itself
  * Added help and usage message
  * Decorate release body
  • Loading branch information
hsbt committed Feb 10, 2023
1 parent 2c8e4aa commit 07bf97e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tool/gen-github-release.rb
@@ -1,5 +1,11 @@
#!/usr/bin/env ruby

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

require "bundler/inline"

gemfile do
Expand All @@ -19,6 +25,8 @@

client = Octokit::Client.new

note = "## What's Changed\n\n"

diff = client.compare("ruby/ruby", ARGV[0], ARGV[1])
diff[:commits].each do |c|
if c[:commit][:message] =~ /\[Backport #(\d*)\]/
Expand All @@ -32,8 +40,20 @@
else
next
end
puts "* [#{title}](#{url})"
note << "* [#{title}](#{url})\n"
rescue OpenURI::HTTPError
puts "Error: #{url}"
end

note << "\n"
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"
name = ARGV[1].gsub(/v/, "").gsub(/_/, ".")
client.create_release("ruby/ruby", ARGV[1], name: name, body: note)
puts "Created a release: https://github.com/ruby/ruby/releases/tag/#{ARGV[1]}"
else
puts note
end

0 comments on commit 07bf97e

Please sign in to comment.