diff options
author | Tom Duffield <tom@chef.io> | 2017-03-07 08:09:35 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-07 08:09:35 -0600 |
commit | ca358ef6e77621e8ae250e4c2675cc9a9a95c8d1 (patch) | |
tree | 96b54a143e508f4e747775a19be5b244d01abb29 | |
parent | 29c39b56764a52945609b0eeb0f6068da6ed0041 (diff) | |
parent | ef38cd3691bf3ecd08cd88c83b41611ebf95cd7e (diff) | |
download | chef-ca358ef6e77621e8ae250e4c2675cc9a9a95c8d1.tar.gz |
Merge pull request #5834 from chef/tduffield/update-version-bumping
Improve version bumping
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Rakefile | 20 | ||||
-rw-r--r-- | chef-config/lib/chef-config/package_task.rb | 14 | ||||
-rwxr-xr-x | ci/bundle_install.sh | 2 | ||||
-rwxr-xr-x | ci/version_bump.sh | 4 | ||||
-rw-r--r-- | tasks/version.rb | 41 |
6 files changed, 60 insertions, 25 deletions
@@ -53,7 +53,7 @@ group(:docgen) do gem "yard" end -group(:maintenance) do +group(:maintenance, :ci) do gem "tomlrb" # To sync maintainers with github @@ -80,7 +80,7 @@ group(:development, :test) do gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master" end -group(:changelog) do +group(:ci) do gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator" gem "mixlib-install" end @@ -29,30 +29,12 @@ require_relative "tasks/cbgb" require_relative "tasks/dependencies" require_relative "tasks/changelog" require_relative "tasks/announce" +require_relative "tasks/version" ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package| package.component_paths = ["chef-config"] package.generate_version_class = true end -# Add conservative dependency update to version:bump (which was created by PackageTask) -task "version:bump" => %w{version:bump_patch version:update} -task "version:bump" => %w{version:bump_patch version:update} - -task "version:bump_minor" do - Rake::Task["changelog:archive"].invoke - maj, min, _build = Chef::VERSION.split(".") - File.open("VERSION", "w+") { |f| f.write("#{maj}.#{min.to_i + 1}.0") } - Rake::Task["version"].invoke - Rake::Task["bundle:install"].invoke -end - -task "version:bump_major" do - Rake::Task["changelog:archive"].invoke - maj, _min, _build = Chef::VERSION.split(".") - File.open("VERSION", "w+") { |f| f.write("#{maj.to_i + 1}.0.0") } - Rake::Task["version"].invoke - Rake::Task["bundle:install"].invoke -end task :pedant, :chef_zero_spec diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index de830c09d3..6c4ca4f435 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -182,6 +182,20 @@ module ChefConfig IO.write(version_file_path, new_version) end + task :bump_minor do + current_version = version + new_version = current_version.sub(/^(\d+)\.(\d+)\.(\d+)/) { "#{$1}.#{$2.to_i + 1}.0" } + puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" + IO.write(version_file_path, new_version) + end + + task :bump_major do + current_version = version + new_version = current_version.sub(/^(\d+)\.(\d+\.\d+)/) { "#{$1.to_i + 1}.0.0" } + puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" + IO.write(version_file_path, new_version) + end + def update_version_rb # rubocop:disable Lint/NestedMethodDefinition puts "Updating #{version_rb_path} to include version #{version} ..." contents = <<-VERSION_RB diff --git a/ci/bundle_install.sh b/ci/bundle_install.sh index 4eecec9f18..bb1d9694db 100755 --- a/ci/bundle_install.sh +++ b/ci/bundle_install.sh @@ -5,6 +5,6 @@ set -evx gem environment bundler_version=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) gem install bundler -v $bundler_version --user-install --conservative -# WITH: changelog (for version bumping and changelog creation) +# WITH: ci (for version bumping and changelog creation) export BUNDLE_WITHOUT=omnibus_package:test:pry:integration:docgen:maintenance:travis:aix:bsd:linux:mac_os_x:solaris:windows:development:travis bundle _${bundler_version}_ install diff --git a/ci/version_bump.sh b/ci/version_bump.sh index ed2229ecc3..4b5ba5236b 100755 --- a/ci/version_bump.sh +++ b/ci/version_bump.sh @@ -6,8 +6,6 @@ export LANG=en_US.UTF-8 . ci/bundle_install.sh -bundle exec rake version:bump -bundle exec rake changelog || true -bundle exec rake update_dockerfile +bundle exec rake ci_version_bump git checkout .bundle/config diff --git a/tasks/version.rb b/tasks/version.rb new file mode 100644 index 0000000000..812d7001d1 --- /dev/null +++ b/tasks/version.rb @@ -0,0 +1,41 @@ +# +# Copyright:: Copyright 2017 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +task :ci_version_bump do + begin + require "rake" + + Rake::Task["version:bump_minor"].invoke + Rake::Task["version:update"].invoke + + # We want to log errors that occur in the following tasks, but we don't + # want them to stop an otherwise valid version bump from progressing. + begin + Rake::Task["changelog:update"].invoke + rescue Exception => e + puts "There was an error updating the CHANGELOG" + puts e + end + + begin + Rake::Task["update_dockerfile"].invoke + rescue Exception => e + puts "There was an error updating the Dockerfile" + puts e + end + end +end |