From cf22046b51c641be8338c669e871e292f4a6188f Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 21 Mar 2016 15:29:08 -0700 Subject: Add version:bump and version:show tasks for version-bump-bot --- Gemfile | 2 +- chef-config/lib/chef-config/package_task.rb | 36 +++++++++++++++++++++++------ chef-config/lib/chef-config/version.rb | 2 +- lib/chef/version.rb | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 141d593266..e39a50a586 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ gemspec name: "chef" gem "activesupport", "< 4.0.0", group: :compat_testing, platform: "ruby" -gem "chef-config", path: "chef-config" if File.exist?(__FILE__ + "../chef-config") +gem "chef-config", path: "chef-config" if File.exist?(File.expand_path("../chef-config", __FILE__)) # Ensure that we can always install rake, regardless of gem groups gem "rake" diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index 1860335854..d6f7e55415 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -83,8 +83,12 @@ module ChefConfig module_name == "Chef" ? root_path : File.dirname(root_path) end + def version_file_path + File.join(chef_root_path, "VERSION") + end + def version - IO.read(File.join(chef_root_path, "VERSION")).strip + IO.read(version_file_path).strip end def full_package_dir @@ -148,9 +152,10 @@ module ChefConfig end end - desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file' - task :version => :update_components_versions do - contents = <<-VERSION_RB + namespace :version do + desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file' + task :update => :update_components_versions do + contents = <<-VERSION_RB # Copyright:: Copyright 2010-2016, Chef Software, Inc. # License:: Apache License, Version 2.0 # @@ -173,7 +178,7 @@ module ChefConfig #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #{class_or_module} #{module_name} - #{module_name.upcase}_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__))) + #{module_name.upcase}_ROOT = File.expand_path("../..", __FILE__) VERSION = "#{version}" end @@ -185,10 +190,27 @@ end # pre-release versions like "10.14.0.rc.2". Please use Rubygem's # Gem::Version class instead. # - VERSION_RB - IO.write(version_rb_path, contents) + VERSION_RB + IO.write(version_rb_path, contents) + end + + task :bump => %w{version:bump_patch version:update} + + task :show do + puts version + end + + # Add 1 to the current patch version in the VERSION file, and write it back out. + task :bump_patch do + current_version = version + new_version = current_version.sub(/^(\d+\.\d+\.)(\d+)/) { "#{$1}#{$2.to_i + 1}" } + puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" + IO.write(version_file_path, new_version) + end end + task :version => 'version:update' + Dir[File.expand_path("*gemspec", root_path)].reverse_each do |gemspec_path| gemspec = eval(IO.read(gemspec_path)) Gem::PackageTask.new(gemspec) do |task| diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 38635885c6..4d36a2c4b1 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -20,7 +20,7 @@ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module ChefConfig - CHEFCONFIG_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__))) + CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) VERSION = "12.8.1" end diff --git a/lib/chef/version.rb b/lib/chef/version.rb index c1a094c663..01240e91fd 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -20,7 +20,7 @@ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! class Chef - CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__))) + CHEF_ROOT = File.expand_path("../..", __FILE__) VERSION = "12.8.1" end -- cgit v1.2.1