Rakefile 3.2 KB

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