tasks/github_changelog_generator.rb in chef-dk-1.0.3 vs tasks/github_changelog_generator.rb in chef-dk-1.1.16

- old
+ new

@@ -15,19 +15,37 @@ # limitations under the License. # begin require "github_changelog_generator/task" + require "mixlib/install" - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - config.user = "chef" - config.project = "chef-dk" - config.future_release = ChefDK::VERSION - config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",") - config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",") - config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",") -# Makes life easier by only generating changelogs between said tags. -# config.between_tags = "v0.15.15,v0.16.28".split(",") + namespace :changelog do + # Fetch the latest version from mixlib-install + latest_stable_version = Mixlib::Install.available_versions("chefdk", "stable").last + + # Take the changelog from the latest stable release and put it into history. + desc "Archive current CHANGELOG to HISTORY" + task :archive do + changelog = Net::HTTP.get(URI("https://raw.githubusercontent.com/chef/chef-dk/v#{latest_stable_version}/CHANGELOG.md")).chomp.split("\n") + File.open("HISTORY.md", "w+") { |f| f.write(changelog[2..-4].join("\n")) } + end + + # Run this to just update the changelog for the current release. This will + # take what is in HISTORY and generate a changelog of PRs between the most + # recent stable version and HEAD. + GitHubChangelogGenerator::RakeTask.new :update do |config| + config.future_release = "v#{ChefDK::VERSION}" + config.between_tags = ["v#{latest_stable_version}", "v#{ChefDK::VERSION}"] + config.max_issues = 0 + config.add_issues_wo_labels = false + config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",") + config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",") + config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",") + config.header = "This changelog reflects the current state of chef-dk's master branch on github and may not reflect the current released version of chef-dk, which is [![Gem Version](https://badge.fury.io/rb/chef-dk.svg)](https://badge.fury.io/rb/chef-dk)." + end end + + task :changelog => "changelog:update" rescue LoadError puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs" end