Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ RSpec::Core::RakeTask.new(:rspec)

desc 'Build the bson gem'
task :build => [ :clean_all, *(jruby? ? :compile : nil) ] do
output = "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
system "gem build #{output} bson.gemspec"
command = [ 'gem', 'build' ]
command << "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
command << ENV['GEMSPEC'] || 'bson.gemspec'
system(*command)
end

# `rake version` is used by the deployment system so get the release version
Expand All @@ -66,22 +68,10 @@ task :version do
puts BSON::VERSION
end

# `rake gem_file_name` is used by the deployment system so get the name of
# the gem file to be generated. It must do nothing more than just print the
# name of the gem file to generate.
desc 'Print the name of the gem file to generate.'
task :gem_file_name do
require 'bson/version'
base = "bson-#{BSON::VERSION}"
base << '-java' if jruby?
puts "#{base}.gem"
end

task :clean_all => :clean do
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.bundle"))
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.so"))
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.o"))
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson-ruby.jar"))
%w[ bson-ruby.jar bson_native.bundle bson_native.so bson_native.o ].each do |file|
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', file))
end
end

task :spec => :compile do
Expand All @@ -93,15 +83,6 @@ end
# been built (and signed via GPG), so we just need `rake release` to
# push the gem to rubygems.
task :release do
require 'bson/version'

# confirm: there ought to be two gems, one for MRI, and one for Java. These
# will have been previously generated by the 'BSON Release' GitHub action.
gems = Dir['*.gem']
if gems.length != 2
abort "Expected two gem files to be ready to release; got #{gems.length}"
end

if ENV['GITHUB_ACTION'].nil?
abort <<~WARNING
`rake release` must be invoked from the `BSON Release` GitHub action,
Expand All @@ -116,6 +97,13 @@ task :release do
WARNING
end

# confirm: there ought to be two gems, one for MRI, and one for Java. These
# will have been previously generated by the 'build' job.
gems = Dir['*.gem']
if gems.length != 2
abort "Expected two gem files to be ready to release; got #{gems.inspect}"
end

gems.each do |gem|
system 'gem', 'push', gem
end
Expand Down
Loading