summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Duffield <tom@chef.io>2017-02-10 21:35:14 -0600
committerTom Duffield <tom@chef.io>2017-02-13 09:47:21 -0600
commitc5801187f978f6d43017f63d0fbd2c714d273395 (patch)
treed938d6b7ead6f54f675ea6f5687239cb8254e183
parentb949a48acc21d4b64869bd7b834708d5232b1f2a (diff)
downloadchef-tduffield/add-label-version-bumping.tar.gz
Bump the version of chef depending on the label associated with PRtduffield/add-label-version-bumping
Signed-off-by: Tom Duffield <tom@chef.io>
-rw-r--r--Gemfile4
-rw-r--r--Rakefile20
-rw-r--r--acceptance/Gemfile.lock16
-rw-r--r--chef-config/lib/chef-config/package_task.rb14
-rwxr-xr-xci/bundle_install.sh2
-rwxr-xr-xci/version_bump.sh4
-rw-r--r--kitchen-tests/Gemfile.lock16
-rw-r--r--omnibus/Gemfile.lock14
-rw-r--r--tasks/version.rb81
9 files changed, 123 insertions, 48 deletions
diff --git a/Gemfile b/Gemfile
index b3fa6b01a3..cc664c40ce 100644
--- a/Gemfile
+++ b/Gemfile
@@ -50,7 +50,7 @@ group(:docgen) do
gem "yard"
end
-group(:maintenance) do
+group(:maintenance, :ci) do
gem "tomlrb"
# To sync maintainers with github
@@ -77,7 +77,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
diff --git a/Rakefile b/Rakefile
index 311639230b..34d62788ea 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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/acceptance/Gemfile.lock b/acceptance/Gemfile.lock
index 8dfb2ec217..cde1cdb530 100644
--- a/acceptance/Gemfile.lock
+++ b/acceptance/Gemfile.lock
@@ -12,13 +12,13 @@ GEM
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
artifactory (2.6.0)
- aws-sdk (2.7.5)
- aws-sdk-resources (= 2.7.5)
- aws-sdk-core (2.7.5)
+ aws-sdk (2.7.7)
+ aws-sdk-resources (= 2.7.7)
+ aws-sdk-core (2.7.7)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.7.5)
- aws-sdk-core (= 2.7.5)
+ aws-sdk-resources (2.7.7)
+ aws-sdk-core (= 2.7.7)
aws-sigv4 (1.0.0)
berkshelf (5.6.2)
addressable (~> 2.3, >= 2.3.4)
@@ -75,7 +75,7 @@ GEM
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
- hashie (3.5.1)
+ hashie (3.5.2)
hitimes (1.2.4)
httpclient (2.8.3)
inspec (1.14.1)
@@ -96,7 +96,7 @@ GEM
train (>= 0.22.0, < 1.0)
jmespath (1.3.1)
json (2.0.3)
- kitchen-ec2 (1.2.0)
+ kitchen-ec2 (1.3.0)
aws-sdk (~> 2)
excon
multi_json
@@ -106,7 +106,7 @@ GEM
hashie (~> 3.4)
inspec (>= 0.34.0, < 2.0.0)
test-kitchen (~> 1.6)
- kitchen-vagrant (1.0.0)
+ kitchen-vagrant (1.0.1)
test-kitchen (~> 1.4)
little-plugger (1.1.4)
logging (2.1.0)
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/kitchen-tests/Gemfile.lock b/kitchen-tests/Gemfile.lock
index b9d14397f1..7e199aeac7 100644
--- a/kitchen-tests/Gemfile.lock
+++ b/kitchen-tests/Gemfile.lock
@@ -4,13 +4,13 @@ GEM
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
artifactory (2.6.0)
- aws-sdk (2.7.5)
- aws-sdk-resources (= 2.7.5)
- aws-sdk-core (2.7.5)
+ aws-sdk (2.7.7)
+ aws-sdk-resources (= 2.7.7)
+ aws-sdk-core (2.7.7)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.7.5)
- aws-sdk-core (= 2.7.5)
+ aws-sdk-resources (2.7.7)
+ aws-sdk-core (= 2.7.7)
aws-sigv4 (1.0.0)
berkshelf (5.6.2)
addressable (~> 2.3, >= 2.3.4)
@@ -68,7 +68,7 @@ GEM
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
- hashie (3.5.1)
+ hashie (3.5.2)
hitimes (1.2.4)
hitimes (1.2.4-x86-mingw32)
httpclient (2.8.3)
@@ -94,7 +94,7 @@ GEM
kitchen-dokken (1.1.0)
docker-api (~> 1.33)
test-kitchen (~> 1.13)
- kitchen-ec2 (1.2.0)
+ kitchen-ec2 (1.3.0)
aws-sdk (~> 2)
excon
multi_json
@@ -104,7 +104,7 @@ GEM
hashie (~> 3.4)
inspec (>= 0.34.0, < 2.0.0)
test-kitchen (~> 1.6)
- kitchen-vagrant (1.0.0)
+ kitchen-vagrant (1.0.1)
test-kitchen (~> 1.4)
little-plugger (1.1.4)
logging (2.1.0)
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index ceb322bf20..dab601be2d 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/chef/license_scout.git
- revision: f90293a9753652fb64994a14de4108e503c06632
+ revision: 1547c05652ee8b72f0dff673893c0f826434d596
specs:
license_scout (0.1.2)
ffi-yajl (~> 2.2)
@@ -39,13 +39,13 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
artifactory (2.6.0)
awesome_print (1.7.0)
- aws-sdk (2.7.5)
- aws-sdk-resources (= 2.7.5)
- aws-sdk-core (2.7.5)
+ aws-sdk (2.7.7)
+ aws-sdk-resources (= 2.7.7)
+ aws-sdk-core (2.7.7)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.7.5)
- aws-sdk-core (= 2.7.5)
+ aws-sdk-resources (2.7.7)
+ aws-sdk-core (= 2.7.7)
aws-sigv4 (1.0.0)
berkshelf (4.3.5)
addressable (~> 2.3, >= 2.3.4)
@@ -107,7 +107,7 @@ GEM
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
- hashie (3.5.1)
+ hashie (3.5.2)
hitimes (1.2.4)
hitimes (1.2.4-x86-mingw32)
httpclient (2.7.2)
diff --git a/tasks/version.rb b/tasks/version.rb
new file mode 100644
index 0000000000..91d91ffb08
--- /dev/null
+++ b/tasks/version.rb
@@ -0,0 +1,81 @@
+#
+# 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.
+#
+
+BUMP_PATCH_LABEL = "Version: Bump Patch"
+BUMP_MINOR_LABEL = "Version: Bump Minor"
+BUMP_MAJOR_LABEL = "Version: Bump Major"
+
+# Temporary setting to keep current behavior. If there is no
+# label, bump patch. Setting this to false will cause PRs
+# without a version label to _not_ get a version bump.
+BUMP_PATH_WITH_NO_LABEL = true
+
+task :ci_version_bump do
+ begin
+ require "rake"
+ require "octokit"
+
+ client = Octokit::Client.new(:netrc => true)
+ begin
+ issue_id = `git log --format=%B -n 1 HEAD`.match(/Merge pull request #(\d+)/)[1]
+ puts "Getting Issue labels from PR ##{issue_id}"
+ rescue NoMethodError
+ puts "This commit was not associated with a Github PR - not bumping the version."
+ exit 0
+ end
+
+ issue = github.issue("chef/chef", issue_id)
+ labels = issue[:labels].select { |i| [BUMP_PATCH_LABEL, BUMP_MINOR_LABEL, BUMP_MAJOR_LABEL].include?(i[:name]) }
+
+ if labels.length < 1 && !BUMP_PATH_WITH_NO_LABEL
+ puts "We didn't find any valid Version labels on the PR."
+ exit 0
+ end
+
+ if labels.length > 1
+ puts "There can only be one valid Version label per PR."
+ raise
+ end
+
+ case labels.first[:name]
+ when BUMP_MAJOR_LABEL
+ Rake::Task["version:bump_major"].invoke
+ when BUMP_MINOR_LABEL
+ Rake::Task["version:bump_minor"].invoke
+ else
+ Rake::Task["version:bump_patch"].invoke
+ end
+
+ 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