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"
raise "#{filename} is not a file" unless File.file? 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
def header str, token = "#"

View File

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