diff --git a/Rakefile b/Rakefile index ec1ba6f16..83c536209 100644 --- a/Rakefile +++ b/Rakefile @@ -17,6 +17,9 @@ task :changelog, [:version] do |_t, args| sh "scripts/generate_changelog.rb #{args[:version]}" end +desc 'Prepare for a release' +task 'release:prepare' => [:changelog] + desc "Check for new versions of bundled modules" task :update_modules do sh "scripts/update_modules.rb" diff --git a/rakelib/vox.rake b/rakelib/vox.rake new file mode 100644 index 000000000..f6bcbcd98 --- /dev/null +++ b/rakelib/vox.rake @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +namespace :vox do + desc 'Update the version in preparation for a release' + task 'version:bump:full', [:version] do |_, args| + abort 'You must provide a tag.' if args[:version].nil? || args[:version].empty? + version = args[:version] + abort "#{version} does not appear to be a valid version string in x.y.z format" unless Gem::Version.correct?(version) + + # Update lib/bolt/version.rb and openbolt.gemspec + puts "Setting version to #{version}" + + data = File.read('lib/bolt/version.rb') + new_data = data.sub(/VERSION = '\d+\.\d+\.\d+(-\w+(\..*)?)?'/, "VERSION = '#{version}'") + if data != new_data + File.write('lib/bolt/version.rb', new_data) + else + warn 'Failed to update version in lib/bolt/version.rb' + end + + data = File.read('openbolt.gemspec') + new_data = data.sub(/(spec.version *=) '\d+\.\d+\.\d+(-\w+(\.\w+)?)?'/, "\\1 '#{version}'") + if data != new_data + File.write('openbolt.gemspec', new_data) + else + warn 'Failed to update version in openbolt.gemspec' + end + end +end +