Skip to content

Commit 4c9181f

Browse files
authored
chore: Attempt to fix the releaser (#2218)
1 parent d6d481e commit 4c9181f

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

Rakefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ def load_env_vars
7474
filename = "#{ENV['KOKORO_GFILE_DIR']}/ruby_env_vars.json"
7575
raise "#{filename} is not a file" unless File.file? filename
7676
env_vars = JSON.parse File.read(filename)
77-
env_vars.each { |k, v| ENV[k] ||= v }
77+
env_vars.each do |k, v|
78+
if ENV[k]
79+
puts "Ignoring #{k} because it is already set"
80+
else
81+
puts "Setting #{k}"
82+
end
83+
ENV[k] ||= v
84+
end
7885
end
7986

8087
def header str, token = "#"

rakelib/releaser.rb

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def needs_gem_publish?
3737

3838
def publish_gem
3939
configure_rubygems_api_token
40-
bundle_dir do
40+
Dir.chdir(gem_dir) do
4141
FileUtils.rm_rf("pkg")
42-
execute "bundle exec rake build"
42+
isolate_bundle do
43+
execute "bundle exec rake build"
44+
end
4345
built_gem_path = "pkg/#{gem_name}-#{gem_version}.gem"
4446
raise "Failed to build #{built_gem_path}" unless File.file?(built_gem_path)
4547
if dry_run?
@@ -53,10 +55,12 @@ def publish_gem
5355
end
5456

5557
def publish_docs
56-
bundle_dir do
58+
Dir.chdir(gem_dir) do
5759
FileUtils.rm_rf("doc")
5860
FileUtils.rm_rf(".yardoc")
59-
execute "bundle exec rake yard"
61+
isolate_bundle do
62+
execute "bundle exec rake yard"
63+
end
6064
Dir.chdir("doc") do
6165
execute "python3 -m docuploader create-metadata" \
6266
" --name #{gem_name}" \
@@ -117,25 +121,24 @@ def configure_rubygems_api_token
117121
Gems.configure do |config|
118122
config.key = rubygems_api_token
119123
end
124+
puts "Configured rubygems api token"
120125
end
121126
end
122127

123-
def bundle_dir
128+
def isolate_bundle
124129
block = proc do
125130
execute "bundle update" unless @bundle_updated
126131
@bundle_updated = true
127132
yield
128133
end
129-
Dir.chdir(gem_dir) do
130-
if defined?(Bundler)
131-
if Bundler.respond_to?(:with_unbundled_env)
132-
Bundler.with_unbundled_env(&block)
133-
else
134-
Bundler.with_clean_env(&block)
135-
end
134+
if defined?(Bundler)
135+
if Bundler.respond_to?(:with_unbundled_env)
136+
Bundler.with_unbundled_env(&block)
136137
else
137-
block.call
138+
Bundler.with_clean_env(&block)
138139
end
140+
else
141+
block.call
139142
end
140143
end
141144

0 commit comments

Comments
 (0)