tasks/version.rb in chef-dk-1.3.40 vs tasks/version.rb in chef-dk-1.3.43

- old
+ new

@@ -40,10 +40,11 @@ namespace :version do desc "Bump patch version in lib/chef-dk/version.rb and update Gemfile*.lock conservatively to include the new version. If Gemfile has changed, this will update modified constraints as well." task :bump => "ci_version_bump" + # Can be deleted when we migrate fully to expeditor desc "Show the current version." task :show do puts version end @@ -53,10 +54,14 @@ else raise "Could not read version from #{version_rb_path}. Contents:\n#{IO.read(version_rb_path)}" end end + def version_file + File.expand_path("../../VERSION", __FILE__) + end + def version_rb_path File.expand_path("../../lib/chef-dk/version.rb", __FILE__) end def gemfile_lock_path @@ -65,10 +70,11 @@ def release_notes_path File.expand_path("../../RELEASE_NOTES.md", __FILE__) end + # Can be deleted when we migrate fully to expeditor # Add 1 to the current patch version in the VERSION file, and write it back out. desc "Bump the patch version in lib/chef-dk/version.rb." task :bump_patch do current_version_file = IO.read(version_rb_path) new_version = nil @@ -78,10 +84,11 @@ end puts "Updating version in #{version_rb_path} from #{version} to #{new_version.chomp}" IO.write(version_rb_path, new_version_file) end + # Can be deleted when we migrate fully to expeditor desc "Bump the minor version in lib/chef-dk/version.rb" task :bump_minor do current_version_file = IO.read(version_rb_path) new_version = nil new_version_file = current_version_file.sub(/^(\s*VERSION\s*=\s*")(\d+)\.(\d+)\.(\d+)/) do @@ -94,10 +101,11 @@ Rake::Task["changelog::archive"].invoke Rake::Task["version:update_gemfile_lock"].invoke Rake::Task["bundle:install"].invoke end + # Can be deleted when we migrate fully to expeditor desc "Bump the major version in lib/chef-dk/version.rb" task :bump_major do current_version_file = IO.read(version_rb_path) new_version = nil new_version_file = current_version_file.sub(/^(\s*VERSION\s*=\s*")(\d+)\.(\d+)\.(\d+)/) do @@ -110,9 +118,27 @@ Rake::Task["changelog::archive"].invoke Rake::Task["version:update_gemfile_lock"].invoke Rake::Task["bundle:install"].invoke end + # Called from .expeditor/update_version.sh + desc "Propogate the version from VERSION to the necessary parts of the repo" + task :update do + version = IO.read(version_file).chomp + + updated_version_file = IO.read(version_rb_path).sub(/^(\s*VERSION\s*=\s*")(\d+\.\d+\.\d+)/) do + "#{$1}#{version}" + end + + updated_gemfile_lock = IO.read(gemfile_lock_path).gsub!(/^\s*(chef-dk)\s*\((= )?\S+\)\s*$/) do |line| + line.gsub(/\((= )?\d+(\.\d+)+/) { "(#{$1}#{version}" } + end + + IO.write(version_rb_path, updated_version_file) + IO.write(gemfile_lock_path, updated_gemfile_lock) + end + + # Can be deleted when we migrate fully to expeditor desc "Update the Gemfile.lock to include the current chef-dk version" task :update_gemfile_lock do if File.exist?(gemfile_lock_path) puts "Updating #{gemfile_lock_path} to include version #{version} ..." contents = IO.read(gemfile_lock_path)