You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Rakefile 3.6KB

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