Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / Rakefile
1 require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
2 require 'puppetlabs_spec_helper/rake_tasks'
3 require 'puppet-syntax/tasks/puppet-syntax'
4 require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
5 require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
6 require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
7 require 'puppet_pot_generator/rake_tasks'
8
9 def changelog_user
10   return unless Rake.application.top_level_tasks.include? "changelog"
11   returnVal = nil || JSON.load(File.read('metadata.json'))['author']
12   raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
13   puts "GitHubChangelogGenerator user:#{returnVal}"
14   returnVal
15 end
16
17 def changelog_project
18   return unless Rake.application.top_level_tasks.include? "changelog"
19   returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1]
20   raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
21   puts "GitHubChangelogGenerator project:#{returnVal}"
22   returnVal
23 end
24
25 def changelog_future_release
26   return unless Rake.application.top_level_tasks.include? "changelog"
27   returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
28   raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
29   puts "GitHubChangelogGenerator future_release:#{returnVal}"
30   returnVal
31 end
32
33 PuppetLint.configuration.send('disable_relative')
34
35 if Bundler.rubygems.find_name('github_changelog_generator').any?
36   GitHubChangelogGenerator::RakeTask.new :changelog do |config|
37     raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
38     config.user = "#{changelog_user}"
39     config.project = "#{changelog_project}"
40     config.future_release = "#{changelog_future_release}"
41     config.exclude_labels = ['maintenance']
42     config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
43     config.add_pr_wo_labels = true
44     config.issues = false
45     config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
46     config.configure_sections = {
47       "Changed" => {
48         "prefix" => "### Changed",
49         "labels" => ["backwards-incompatible"],
50       },
51       "Added" => {
52         "prefix" => "### Added",
53         "labels" => ["feature", "enhancement"],
54       },
55       "Fixed" => {
56         "prefix" => "### Fixed",
57         "labels" => ["bugfix"],
58       },
59     }
60   end
61 else
62   desc 'Generate a Changelog from GitHub'
63   task :changelog do
64     raise <<EOM
65 The changelog tasks depends on unreleased features of the github_changelog_generator gem.
66 Please manually add it to your .sync.yml for now, and run `pdk update`:
67 ---
68 Gemfile:
69   optional:
70     ':development':
71       - gem: 'github_changelog_generator'
72         git: 'https://github.com/skywinder/github-changelog-generator'
73         ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
74         condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
75 EOM
76   end
77 end
78