pmd/.travis/render_release_notes.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2018-08-15 01:52:31 +02:00
#!/usr/bin/env ruby
# Renders the release notes for Github releases,
# and prints them to standard output
# Doesn't trim the header, which is done in shell
# Args:
2018-08-15 02:06:14 +02:00
# ARGV[0] : location of the file to render
2018-08-15 01:52:31 +02:00
require "liquid"
2018-08-15 03:08:46 +02:00
require "safe_yaml"
2018-08-15 01:52:31 +02:00
# include some custom liquid extensions
2018-11-14 20:47:18 +01:00
require_relative "../docs/_plugins/all_extensions"
2018-08-15 01:52:31 +02:00
# explicitly setting safe mode to get rid of the warning
SafeYAML::OPTIONS[:default_mode] = :safe
2018-08-15 01:52:31 +02:00
# START OF THE SCRIPT
2018-08-15 02:46:54 +02:00
unless ARGV.length == 1 && File.exists?(ARGV[0])
2018-11-14 20:47:18 +01:00
print "\e[31m[ERROR] In #{$0}: The first arg must be a valid file name\e[0m\n"
2018-08-15 02:46:54 +02:00
exit 1
2018-08-15 01:52:31 +02:00
end
release_notes_file = ARGV[0]
2018-11-14 20:47:18 +01:00
# Make the script execute wherever we are
travis_dir = File.expand_path File.dirname(__FILE__)
2018-08-15 03:08:46 +02:00
liquid_env = {
# wrap the config under a "site." namespace because that's how jekyll does it
2018-11-14 20:47:18 +01:00
'site' => YAML.load_file(travis_dir + "/../docs/_config.yml"),
2018-08-15 03:08:46 +02:00
# This signals the links in {% rule %} tags that they should be rendered as absolute
'is_release_notes_processor' => true
}
2018-08-15 01:52:31 +02:00
to_render = File.read(release_notes_file)
rendered = Liquid::Template.parse(to_render).render(liquid_env)
print(rendered)