@@ -53,8 +53,10 @@ RSpec::Core::RakeTask.new(:rspec)
5353
5454desc 'Build the bson gem'
5555task :build => [ :clean_all , *( jruby? ? :compile : nil ) ] do
56- output = "--output=#{ ENV [ 'GEM_FILE_NAME' ] } " if ENV [ 'GEM_FILE_NAME' ]
57- system "gem build #{ output } bson.gemspec"
56+ command = [ 'gem' , 'build' ]
57+ command << "--output=#{ ENV [ 'GEM_FILE_NAME' ] } " if ENV [ 'GEM_FILE_NAME' ]
58+ command << ENV [ 'GEMSPEC' ] || 'bson.gemspec'
59+ system ( *command )
5860end
5961
6062# `rake version` is used by the deployment system so get the release version
@@ -66,22 +68,10 @@ task :version do
6668 puts BSON ::VERSION
6769end
6870
69- # `rake gem_file_name` is used by the deployment system so get the name of
70- # the gem file to be generated. It must do nothing more than just print the
71- # name of the gem file to generate.
72- desc 'Print the name of the gem file to generate.'
73- task :gem_file_name do
74- require 'bson/version'
75- base = "bson-#{ BSON ::VERSION } "
76- base << '-java' if jruby?
77- puts "#{ base } .gem"
78- end
79-
8071task :clean_all => :clean do
81- FileUtils . rm_f ( File . join ( File . dirname ( __FILE__ ) , 'lib' , "bson_native.bundle" ) )
82- FileUtils . rm_f ( File . join ( File . dirname ( __FILE__ ) , 'lib' , "bson_native.so" ) )
83- FileUtils . rm_f ( File . join ( File . dirname ( __FILE__ ) , 'lib' , "bson_native.o" ) )
84- FileUtils . rm_f ( File . join ( File . dirname ( __FILE__ ) , 'lib' , "bson-ruby.jar" ) )
72+ %w[ bson-ruby.jar bson_native.bundle bson_native.so bson_native.o ] . each do |file |
73+ FileUtils . rm_f ( File . join ( File . dirname ( __FILE__ ) , 'lib' , file ) )
74+ end
8575end
8676
8777task :spec => :compile do
9383# been built (and signed via GPG), so we just need `rake release` to
9484# push the gem to rubygems.
9585task :release do
96- require 'bson/version'
97-
98- # confirm: there ought to be two gems, one for MRI, and one for Java. These
99- # will have been previously generated by the 'BSON Release' GitHub action.
100- gems = Dir [ '*.gem' ]
101- if gems . length != 2
102- abort "Expected two gem files to be ready to release; got #{ gems . length } "
103- end
104-
10586 if ENV [ 'GITHUB_ACTION' ] . nil?
10687 abort <<~WARNING
10788 `rake release` must be invoked from the `BSON Release` GitHub action,
@@ -116,6 +97,13 @@ task :release do
11697 WARNING
11798 end
11899
100+ # confirm: there ought to be two gems, one for MRI, and one for Java. These
101+ # will have been previously generated by the 'build' job.
102+ gems = Dir [ '*.gem' ]
103+ if gems . length != 2
104+ abort "Expected two gem files to be ready to release; got #{ gems . inspect } "
105+ end
106+
119107 gems . each do |gem |
120108 system 'gem' , 'push' , gem
121109 end
0 commit comments