Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / Rakefile
1 require 'puppetlabs_spec_helper/rake_tasks'
2 require 'puppet-syntax/tasks/puppet-syntax'
3 require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
4 require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
5 require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
6 require 'puppet-lint/tasks/puppet-lint'
7
8 def changelog_user
9   return unless Rake.application.top_level_tasks.include? "changelog"
10   returnVal = nil || JSON.load(File.read('metadata.json'))['author']
11   raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
12   puts "GitHubChangelogGenerator user:#{returnVal}"
13   returnVal
14 end
15
16 def changelog_project
17   return unless Rake.application.top_level_tasks.include? "changelog"
18   returnVal = nil || JSON.load(File.read('metadata.json'))['name']
19   raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
20   puts "GitHubChangelogGenerator project:#{returnVal}"
21   returnVal
22 end
23
24 def changelog_future_release
25   return unless Rake.application.top_level_tasks.include? "changelog"
26   returnVal = JSON.load(File.read('metadata.json'))['version']
27   raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
28   puts "GitHubChangelogGenerator future_release:#{returnVal}"
29   returnVal
30 end
31
32 PuppetLint.configuration.send('disable_relative')
33
34 if Bundler.rubygems.find_name('github_changelog_generator').any?
35   GitHubChangelogGenerator::RakeTask.new :changelog do |config|
36     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?
37     config.user = "#{changelog_user}"
38     config.project = "#{changelog_project}"
39     config.future_release = "#{changelog_future_release}"
40     config.exclude_labels = ['maintenance']
41     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)."
42     config.add_pr_wo_labels = true
43     config.issues = false
44     config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
45     config.configure_sections = {
46       "Changed" => {
47         "prefix" => "### Changed",
48         "labels" => ["backwards-incompatible"],
49       },
50       "Added" => {
51         "prefix" => "### Added",
52         "labels" => ["feature", "enhancement"],
53       },
54       "Fixed" => {
55         "prefix" => "### Fixed",
56         "labels" => ["bugfix"],
57       },
58     }
59   end
60 else
61   desc 'Generate a Changelog from GitHub'
62   task :changelog do
63     raise <<EOM
64 The changelog tasks depends on unreleased features of the github_changelog_generator gem.
65 Please manually add it to your .sync.yml for now, and run `pdk update`:
66 ---
67 Gemfile:
68   optional:
69     ':development':
70       - gem: 'github_changelog_generator'
71         git: 'https://github.com/skywinder/github-changelog-generator'
72         ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
73         condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
74 EOM
75   end
76 end
77