pmd/.travis/render_release_notes.rb

36 lines
840 B
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"
require "yaml"
# include some custom liquid extensions
require_relative "../docs/_plugins/rule_tag"
require_relative "../docs/_plugins/custom_filters"
# START OF THE SCRIPT
2018-08-15 02:46:54 +02:00
unless ARGV.length == 1 && File.exists?(ARGV[0])
print "\e[31m[ERROR] In #{$0}: The first arg must be a valid file name\e[0m"
exit 1
2018-08-15 01:52:31 +02:00
end
release_notes_file = ARGV[0]
# wrap the config under a "site." namespace because that's how jekyll does it
liquid_env = {'site' => YAML.load_file("docs/_config.yml")}
to_render = File.read(release_notes_file)
rendered = Liquid::Template.parse(to_render).render(liquid_env)
print(rendered)