chore: Attempt to fix the releaser (#2218)

This commit is contained in:
Daniel Azuma 2021-01-06 15:48:03 -08:00 committed by GitHub
parent d6d481ec51
commit 4c9181f8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 14 deletions

View File

@ -74,7 +74,14 @@ def load_env_vars
filename = "#{ENV['KOKORO_GFILE_DIR']}/ruby_env_vars.json" filename = "#{ENV['KOKORO_GFILE_DIR']}/ruby_env_vars.json"
raise "#{filename} is not a file" unless File.file? filename raise "#{filename} is not a file" unless File.file? filename
env_vars = JSON.parse File.read(filename) env_vars = JSON.parse File.read(filename)
env_vars.each { |k, v| ENV[k] ||= v } env_vars.each do |k, v|
if ENV[k]
puts "Ignoring #{k} because it is already set"
else
puts "Setting #{k}"
end
ENV[k] ||= v
end
end end
def header str, token = "#" def header str, token = "#"

View File

@ -37,9 +37,11 @@ class Releaser
def publish_gem def publish_gem
configure_rubygems_api_token configure_rubygems_api_token
bundle_dir do Dir.chdir(gem_dir) do
FileUtils.rm_rf("pkg") FileUtils.rm_rf("pkg")
isolate_bundle do
execute "bundle exec rake build" execute "bundle exec rake build"
end
built_gem_path = "pkg/#{gem_name}-#{gem_version}.gem" built_gem_path = "pkg/#{gem_name}-#{gem_version}.gem"
raise "Failed to build #{built_gem_path}" unless File.file?(built_gem_path) raise "Failed to build #{built_gem_path}" unless File.file?(built_gem_path)
if dry_run? if dry_run?
@ -53,10 +55,12 @@ class Releaser
end end
def publish_docs def publish_docs
bundle_dir do Dir.chdir(gem_dir) do
FileUtils.rm_rf("doc") FileUtils.rm_rf("doc")
FileUtils.rm_rf(".yardoc") FileUtils.rm_rf(".yardoc")
isolate_bundle do
execute "bundle exec rake yard" execute "bundle exec rake yard"
end
Dir.chdir("doc") do Dir.chdir("doc") do
execute "python3 -m docuploader create-metadata" \ execute "python3 -m docuploader create-metadata" \
" --name #{gem_name}" \ " --name #{gem_name}" \
@ -117,16 +121,16 @@ class Releaser
Gems.configure do |config| Gems.configure do |config|
config.key = rubygems_api_token config.key = rubygems_api_token
end end
puts "Configured rubygems api token"
end end
end end
def bundle_dir def isolate_bundle
block = proc do block = proc do
execute "bundle update" unless @bundle_updated execute "bundle update" unless @bundle_updated
@bundle_updated = true @bundle_updated = true
yield yield
end end
Dir.chdir(gem_dir) do
if defined?(Bundler) if defined?(Bundler)
if Bundler.respond_to?(:with_unbundled_env) if Bundler.respond_to?(:with_unbundled_env)
Bundler.with_unbundled_env(&block) Bundler.with_unbundled_env(&block)
@ -137,7 +141,6 @@ class Releaser
block.call block.call
end end
end end
end
def execute(cmd) def execute(cmd)
puts cmd puts cmd