summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-03-21 15:29:08 -0700
committerJohn Keiser <john@johnkeiser.com>2016-03-21 16:26:40 -0700
commitcf22046b51c641be8338c669e871e292f4a6188f (patch)
tree5af3af84111bcbecdc6d5aa3660334a08337bb34
parenta3f7e9cd52e8901cbfc5dfa3d93c032dec2ddb7e (diff)
downloadchef-cf22046b51c641be8338c669e871e292f4a6188f.tar.gz
Add version:bump and version:show tasks for version-bump-botjk/version-bumper
-rw-r--r--Gemfile2
-rw-r--r--chef-config/lib/chef-config/package_task.rb36
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/version.rb2
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