[ruby/stringio] Add push task to push built gems

https://github.com/ruby/stringio/commit/4431eefbad
This commit is contained in:
Sutou Kouhei 2022-04-16 07:08:19 +09:00 committed by git
parent 566fb7fa7d
commit 22f79ae3f7
1 changed files with 30 additions and 0 deletions

30
rakelib/release.rake Normal file
View File

@ -0,0 +1,30 @@
release_task = Rake.application["release"]
release_task.prerequisites.delete("build")
release_task.prerequisites.delete("release:rubygem_push")
release_task_comment = release_task.comment
if release_task_comment
release_task.clear_comments
release_task.comment = release_task_comment.gsub(/ and build.*$/, "")
end
desc "Push built gems"
task "push" do
require "open-uri"
helper = Bundler::GemHelper.instance
gemspec = helper.gemspec
name = gemspec.name
version = gemspec.version.to_s
pkg_dir = "pkg"
mkdir_p(pkg_dir)
["", "-java"].each do |type|
base_url = "https://github.com/ruby/#{name}/releases/download"
url = URI("#{base_url}/v#{version}/#{name}-#{version}#{type}.gem")
path = "#{pkg_dir}/#{File.basename(url.path)}"
url.open do |input|
File.open(path, "wb") do |output|
IO.copy_stream(input, output)
end
helper.__send__(:rubygem_push, path)
end
end
end