From 748f405974fce17415873fdcdd6520134700e4a3 Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Fri, 31 Mar 2017 16:08:25 -0500 Subject: [PATCH 1/5] Add expeditor Expeditor is the next-generation utility that we'll use for version bumping. It will include additional features that we don't currently have like the ability to not bump a version on a specific PR. Signed-off-by: Tom Duffield --- .expeditor/bundle_install.sh | 9 +++++++++ .expeditor/config.yml | 14 ++++++++++++++ .expeditor/update_version.sh | 11 +++++++++++ tasks/version.rb | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .expeditor/bundle_install.sh create mode 100644 .expeditor/config.yml create mode 100644 .expeditor/update_version.sh diff --git a/.expeditor/bundle_install.sh b/.expeditor/bundle_install.sh new file mode 100644 index 000000000..94a3a7a83 --- /dev/null +++ b/.expeditor/bundle_install.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -evx + +gem environment +bundler_version=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) +gem install bundler -v $bundler_version --user-install --conservative +export BUNDLE_WITHOUT=omnibus_package:test:aix:bsd:linux:mac_os_x:solaris:windows:default +bundle install diff --git a/.expeditor/config.yml b/.expeditor/config.yml new file mode 100644 index 000000000..09c2cf5fe --- /dev/null +++ b/.expeditor/config.yml @@ -0,0 +1,14 @@ +product_key: chefdk + +slack: + notify_channel: chef-notify + +docker: + enable: true + build_args: + CHANNEL: "{{channel}}" + VERSION: "{{version}}" + +github: + bump_version_on_merge: true + trigger_build_on_bump: true diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh new file mode 100644 index 000000000..38d3f026e --- /dev/null +++ b/.expeditor/update_version.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -evx + +export LANG=en_US.UTF-8 + +. .expeditor/bundle_install.sh + +bundle exec rake expeditor_update_version + +git checkout .bundle/config diff --git a/tasks/version.rb b/tasks/version.rb index 730fe5fca..f18e4e33e 100644 --- a/tasks/version.rb +++ b/tasks/version.rb @@ -38,6 +38,29 @@ end end +task :expeditor_update_version do + begin + require "rake" + + Rake::Task["version:update_gemfile_lock"].invoke + + 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 + + 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" From 2fd5b547c2316b5960f2742c4510f9d476d5fffe Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Thu, 6 Apr 2017 12:10:45 -0700 Subject: [PATCH 2/5] Add inline documentation to clarify Expeditor steps Signed-off-by: Tom Duffield --- .expeditor/bundle_install.sh | 7 ++++++- .expeditor/update_version.sh | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.expeditor/bundle_install.sh b/.expeditor/bundle_install.sh index 94a3a7a83..0b9e998c7 100644 --- a/.expeditor/bundle_install.sh +++ b/.expeditor/bundle_install.sh @@ -1,9 +1,14 @@ #!/bin/sh +# +# Simple file to perform a minimal bundle install to allow Chef Expeditor to run `rake` commands +# set -evx +# Only install groups required to run the Rake command +export BUNDLE_WITHOUT=omnibus_package:test:aix:bsd:linux:mac_os_x:solaris:windows:default + gem environment bundler_version=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) gem install bundler -v $bundler_version --user-install --conservative -export BUNDLE_WITHOUT=omnibus_package:test:aix:bsd:linux:mac_os_x:solaris:windows:default bundle install diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh index 38d3f026e..664e8b59b 100644 --- a/.expeditor/update_version.sh +++ b/.expeditor/update_version.sh @@ -1,11 +1,23 @@ #!/bin/sh +# +# After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file. +# It then executes this file to update any other files/components with that new version. +# set -evx +# The github-changelog-generator requires that LANG be set export LANG=en_US.UTF-8 +# We need to run a bundle install so that our `bundle exec rake` command will work. . .expeditor/bundle_install.sh +# Run a rake command that will update various files in chef/chef-dk with the new VERSION bundle exec rake expeditor_update_version +# Our `rake` command can sometimes modify this file, but we don't care about the +# changes it makes. Reset it to HEAD. git checkout .bundle/config + +# Once Expeditor finshes executing this script, it will commit the changes and push +# the commit as a new tag corresponding to the value in the VERSION file. From d66bc2da4055815f9b316b92fd9bd3502f1d67e9 Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Thu, 6 Apr 2017 12:34:45 -0700 Subject: [PATCH 3/5] Modify expeditor process via feedback from Lamont Signed-off-by: Tom Duffield --- .expeditor/bundle_install.sh | 14 -------------- .expeditor/update_version.sh | 14 ++++++++++++-- tasks/version.rb | 23 ----------------------- 3 files changed, 12 insertions(+), 39 deletions(-) delete mode 100644 .expeditor/bundle_install.sh diff --git a/.expeditor/bundle_install.sh b/.expeditor/bundle_install.sh deleted file mode 100644 index 0b9e998c7..000000000 --- a/.expeditor/bundle_install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# Simple file to perform a minimal bundle install to allow Chef Expeditor to run `rake` commands -# - -set -evx - -# Only install groups required to run the Rake command -export BUNDLE_WITHOUT=omnibus_package:test:aix:bsd:linux:mac_os_x:solaris:windows:default - -gem environment -bundler_version=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) -gem install bundler -v $bundler_version --user-install --conservative -bundle install diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh index 664e8b59b..15b506e80 100644 --- a/.expeditor/update_version.sh +++ b/.expeditor/update_version.sh @@ -9,11 +9,21 @@ set -evx # The github-changelog-generator requires that LANG be set export LANG=en_US.UTF-8 +# Only install groups required to run the Rake command +export BUNDLE_WITHOUT=omnibus_package:test:aix:bsd:linux:mac_os_x:solaris:windows:default + # We need to run a bundle install so that our `bundle exec rake` command will work. -. .expeditor/bundle_install.sh +gem environment +omnibus_bundler=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) +gem install bundler -v $omnibus_bundler --user-install --conservative +bundle install # Run a rake command that will update various files in chef/chef-dk with the new VERSION -bundle exec rake expeditor_update_version +bundle exec rake version:update_gemfile_lock + +# Run the following commands to update the changelog and dockerfile, but ignore errors. +bundle exec rake changelog:update || true +bundle exec rake update_dockerfile || true # Our `rake` command can sometimes modify this file, but we don't care about the # changes it makes. Reset it to HEAD. diff --git a/tasks/version.rb b/tasks/version.rb index f18e4e33e..730fe5fca 100644 --- a/tasks/version.rb +++ b/tasks/version.rb @@ -38,29 +38,6 @@ end end -task :expeditor_update_version do - begin - require "rake" - - Rake::Task["version:update_gemfile_lock"].invoke - - 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 - - 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" From b56f7a9a53aa077996766b36cb9c562b50b3a8ab Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Thu, 6 Apr 2017 12:47:16 -0700 Subject: [PATCH 4/5] Add more expeditor context to the config Signed-off-by: Tom Duffield --- .expeditor/config.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 09c2cf5fe..5b8aa8262 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -1,8 +1,12 @@ +# The name of the product key for this product from mixlib-install product_key: chefdk +# Slack channel in Chef Software slack to send notifications about build failures, etc slack: notify_channel: chef-notify +# When a version of ChefDK hits the current channel, build a corresponding Docker image +# and publish that image to https://hub.docker.com/r/chef/chefdk docker: enable: true build_args: @@ -10,5 +14,18 @@ docker: VERSION: "{{version}}" github: + # The file where the MAJOR.MINOR.PATCH version is kept + version_file: "VERSION" + + # When a PR is merged, bump the PATCH version bump_version_on_merge: true + + # After the PATCH version has been bumped, execute this script + # to distribute that version to other files in the repository. + update_version_script: ".expeditor/update_version.sh" + + # The tag format Expeditor should use when tagging version commits + version_tag_format: "v{{version}}" + + # After the version is bumped and the tag is pushed to Github, trigger a Jenkins build trigger_build_on_bump: true From ce1e7d0579ab15cf303b135b717ce76e9b65b507 Mon Sep 17 00:00:00 2001 From: Tom Duffield Date: Thu, 6 Apr 2017 17:28:46 -0700 Subject: [PATCH 5/5] Add new Rakefile target that uses VERSION file Please note: the VERSION file is not technically in use yet. I just needed to add it to ensure everything was in place. Signed-off-by: Tom Duffield --- .expeditor/update_version.sh | 2 +- VERSION | 1 + tasks/version.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 VERSION diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh index 15b506e80..62635b94a 100644 --- a/.expeditor/update_version.sh +++ b/.expeditor/update_version.sh @@ -19,7 +19,7 @@ gem install bundler -v $omnibus_bundler --user-install --conservative bundle install # Run a rake command that will update various files in chef/chef-dk with the new VERSION -bundle exec rake version:update_gemfile_lock +bundle exec rake version:update # Run the following commands to update the changelog and dockerfile, but ignore errors. bundle exec rake changelog:update || true diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..227cea215 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.0.0 diff --git a/tasks/version.rb b/tasks/version.rb index 730fe5fca..b6a24a6f0 100644 --- a/tasks/version.rb +++ b/tasks/version.rb @@ -42,6 +42,7 @@ 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 @@ -55,6 +56,10 @@ def version 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 @@ -67,6 +72,7 @@ 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 @@ -80,6 +86,7 @@ def release_notes_path 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) @@ -96,6 +103,7 @@ def release_notes_path 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) @@ -112,6 +120,24 @@ def release_notes_path 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)