Skip to content

Commit

Permalink
Update from choria-plugins modulesync_config
Browse files Browse the repository at this point in the history
  • Loading branch information
ripienaar committed Aug 26, 2024
1 parent 133bc76 commit 0158237
Showing 1 changed file with 25 additions and 47 deletions.
72 changes: 25 additions & 47 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,40 @@ end

task :default => [:test]

desc "Expands the action details section in a README.md file"
task :readme_expand do
ddl_file = Dir.glob("agent/*.ddl").first

return unless ddl_file

ddl = MCollective::DDL.new("package", :agent, false)
ddl.instance_eval(File.read(ddl_file))

lines = File.readlines("puppet/README.md").map do |line|
if line.match?(/^<!--- actions -->/)
[
"## Actions\n\n",
"This agent provides the following actions, for details about each please run `mco plugin doc agent/%s`\n\n" % ddl.meta[:name]
] + ddl.entities.keys.sort.map do |action|
" * **%s** - %s\n" % [action, ddl.entities[action][:description]]
end
else
line
end
end.flatten

File.open("puppet/README.md", "w") do |f|
f.print lines.join
end
end

desc "Set versions for a release"
task :prep_version do
abort("Please specify VERSION") unless ENV["VERSION"]

Rake::FileList["**/*.ddl"].each do |file|
sh 'sed -i"" -re \'s/(\s+:version\s+=>\s+").+/\1%s",/\' %s' % [ENV["VERSION"], file]
sh 'sed -i "" -re \'s/([\t ]+:version[\t ]+=>[\t ]+").+/\\1%s",/\' %s' % [ENV["VERSION"], file]
end
end

desc "Prepares for a release"
task :build_prep do
if ENV["VERSION"]
Rake::Task[:test].execute
Rake::Task[:prep_version].execute
Rake::FileList["**/*.json"].each do |file|
sh 'sed -i "" -re \'s/("version": ").+/\\1%s",/\' %s' % [ENV["VERSION"], file]
end

mkdir_p "puppet"

cp "README.md", "puppet"
cp "CHANGELOG.md", "puppet"
cp "LICENSE", "puppet"
cp "NOTICE", "puppet"

Rake::Task[:readme_expand].execute
end

desc "Builds the module found in the current directory, run build_prep first"
task :build do
sh "/opt/puppetlabs/puppet/bin/mco plugin package --format aiomodulepackage --vendor choria"
changelog = File.read("CHANGELOG.md")
File.open("CHANGELOG.md", "w") do |f|
done = false
changelog.lines.each do |line|
if line =~ /^## / && !done
done = true
puts "Adding a new entry to CHANGELOG.md:"
puts "-------------------- 8< --------------------"
new_entry = <<~END_CHANGELOG
## #{ENV['VERSION']}
Released #{Time.now.strftime('%Y-%m-%d')}
#{`git log --oneline $(git tag | tail -n 1)..HEAD`.lines.map { |l| l.sub(/^/, ' * ')}.join}
END_CHANGELOG
puts new_entry
puts "-------------------- 8< --------------------"
f.puts new_entry
end
f.puts line
end
end
end

# load optional tasks for releases
Expand Down

0 comments on commit 0158237

Please sign in to comment.