зеркало из https://github.com/github/ruby.git
format-release uses the result of GitHub Actions
This commit is contained in:
Родитель
0ba1ea7fbf
Коммит
b2b1279272
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env ruby
|
||||
# https://rubygems.org/gems/diffy
|
||||
require "diffy"
|
||||
require "open-uri"
|
||||
require "yaml"
|
||||
|
||||
Diffy::Diff.default_options.merge!(
|
||||
include_diff_info: true,
|
||||
|
@ -10,24 +12,22 @@ Diffy::Diff.default_options.merge!(
|
|||
class Tarball
|
||||
attr_reader :version, :sha256
|
||||
|
||||
def initialize(path, size, sha1, sha256, sha512)
|
||||
/\A\/(?:[^\/\n]*\/)*(?:ruby-(?<ver>(?<xy>\d+\.\d+)\.\d+(?:-(?:preview|rc)\d+)?)[0-9a-z.\-]+)/ =~ path \
|
||||
or raise "tarball path doesn't mach regexp"
|
||||
@path = path
|
||||
def initialize(version, url, size, sha1, sha256, sha512)
|
||||
@url = url
|
||||
@size = size
|
||||
@sha1 = sha1
|
||||
@sha256 = sha256
|
||||
@sha512 = sha512
|
||||
@version = ver
|
||||
@xy = xy
|
||||
@version = version
|
||||
@xy = version[/\A\d+\.\d+/]
|
||||
end
|
||||
|
||||
def gz?; @path.end_with?('.gz'); end
|
||||
def zip?; @path.end_with?('.zip'); end
|
||||
def bz2?; @path.end_with?('.bz2'); end
|
||||
def xz?; @path.end_with?('.xz'); end
|
||||
def gz?; @url.end_with?('.gz'); end
|
||||
def zip?; @url.end_with?('.zip'); end
|
||||
def bz2?; @url.end_with?('.bz2'); end
|
||||
def xz?; @url.end_with?('.xz'); end
|
||||
|
||||
def ext; @path[/(?:zip|tar\.(?:gz|bz2|xz))\z/]; end
|
||||
def ext; @url[/(?:zip|tar\.(?:gz|bz2|xz))\z/]; end
|
||||
|
||||
def to_md
|
||||
<<eom
|
||||
|
@ -45,31 +45,69 @@ eom
|
|||
# SHA1: 21f62c369661a2ab1b521fd2fa8191a4273e12a1
|
||||
# SHA256: 97cea8aa63dfa250ba6902b658a7aa066daf817b22f82b7ee28f44aec7c2e394
|
||||
# SHA512: 1e2042324821bb4e110af7067f52891606dcfc71e640c194ab1c117f0b941550e0b3ac36ad3511214ac80c536b9e5cfaf8789eec74cf56971a832ea8fc4e6d94
|
||||
def self.parse(wwwdir, file)
|
||||
def self.parse(wwwdir, version)
|
||||
ary = []
|
||||
ver = nil
|
||||
File.read(file).scan(/^\* .*(?:\n .*)*/) do |unit|
|
||||
path, size, sha1, sha256, sha512 = unit.lines.map(&:chomp)
|
||||
path.slice!(0, 2)
|
||||
size = size[/\d+/].to_i
|
||||
sha1 = sha1[/\h{40}/]
|
||||
sha256 = sha256[/\h{64}/]
|
||||
sha512 = sha512[/\h{128}/]
|
||||
tarball = Tarball.new(path, size, sha1, sha256, sha512)
|
||||
if ver
|
||||
raise "mixed versions" if tarball.version != ver
|
||||
else
|
||||
ver = tarball.version
|
||||
end
|
||||
|
||||
unless /\A(\d+)\.(\d+)\.(\d+)(?:-(?:preview|rc)\d+)?\z/ =~ version
|
||||
raise "unexpected version string '#{version}'"
|
||||
end
|
||||
x = $1.to_i
|
||||
y = $2.to_i
|
||||
z = $3.to_i
|
||||
# previous tag for git diff --shortstat
|
||||
# It's only for x.y.0 release
|
||||
if z != 0
|
||||
prev_tag = nil
|
||||
elsif y != 0
|
||||
prev_tag = "v#{x}_#{y-1}_0"
|
||||
prev_ver = "#{x}.#{y-1}.0"
|
||||
elsif x == 3 && y == 0 && z == 0
|
||||
prev_tag = "v2_7_0"
|
||||
prev_ver = "2.7.0"
|
||||
else
|
||||
raise "unexpected version for prev_ver '#{version}'"
|
||||
end
|
||||
|
||||
uri = "https://cache.ruby-lang.org/pub/tmp/ruby-info-#{version}-draft.yml"
|
||||
info = YAML.load(URI(uri).read)
|
||||
if info.size != 1
|
||||
raise "unexpected info.yml '#{uri}'"
|
||||
end
|
||||
info[0]["size"].each_key do |ext|
|
||||
url = info[0]["url"][ext]
|
||||
size = info[0]["size"][ext]
|
||||
sha1 = info[0]["sha1"][ext]
|
||||
sha256 = info[0]["sha256"][ext]
|
||||
sha512 = info[0]["sha512"][ext]
|
||||
tarball = Tarball.new(version, url, size, sha1, sha256, sha512)
|
||||
ary << tarball
|
||||
end
|
||||
xy = ver[/\A\d+\.\d+/]
|
||||
|
||||
if prev_tag
|
||||
# show diff shortstat
|
||||
tag = "v#{version.gsub(/[.\-]/, '_')}"
|
||||
stat = `git diff --shortstat #{prev_tag}..#{tag}`
|
||||
changes, add, delete = stat.scan(/\d+/)
|
||||
puts stat
|
||||
puts <<eom
|
||||
See [NEWS](https://github.com/ruby/ruby/blob/#{tag}/NEWS) or [commit logs](https://github.com/ruby/ruby/compare/#{prev_tag}...#{tag}) for more details.
|
||||
|
||||
With those changes, [stat](https://github.com/ruby/ruby/compare/#{prev_tag}...#{tag}) since Ruby #{prev_ver}!
|
||||
|
||||
その他詳細については、[NEWS](https://github.com/ruby/ruby/blob/#{tag}/NEWS) ファイルまたは[コミットログ](https://github.com/ruby/ruby/compare/#{prev_tag}...#{tag})を参照してください。
|
||||
|
||||
なお、こうした変更により、Ruby #{prev_ver} 以降では [#{changes} 個のファイルに変更が加えられ、#{add} 行の追加と #{delete} 行の削除が行われました](https://github.com/ruby/ruby/compare/#{prev_tag}...#{tag}) !
|
||||
eom
|
||||
end
|
||||
|
||||
xy = version[/\A\d+\.\d+/]
|
||||
puts "## Download\n\n"
|
||||
ary.each do |tarball|
|
||||
puts tarball.to_md
|
||||
end
|
||||
update_branches_yml(ver, xy, wwwdir)
|
||||
update_downloads_yml(ver, xy, wwwdir)
|
||||
update_releases_yml(ver, xy, ary, wwwdir)
|
||||
update_branches_yml(version, xy, wwwdir)
|
||||
update_downloads_yml(version, xy, wwwdir)
|
||||
update_releases_yml(version, xy, ary, wwwdir)
|
||||
ary
|
||||
end
|
||||
|
||||
|
@ -191,7 +229,9 @@ def main
|
|||
STDERR.puts "usage: format-release <dir-of-w.r-l.o> <output-of-make-snapshot>"
|
||||
exit
|
||||
end
|
||||
Tarball.parse(ARGV[0], ARGV[1])
|
||||
wwwdir = ARGV.shift
|
||||
version = ARGV.shift
|
||||
Tarball.parse(wwwdir, version)
|
||||
end
|
||||
|
||||
main
|
||||
|
|
Загрузка…
Ссылка в новой задаче