Skip to content

Commit

Permalink
Rework release preparation tasks
Browse files Browse the repository at this point in the history
This is a follow-up to voxpupuli/modulesync_config#788

Voxpupuli contributors used to update a module version and `rake
changelog` before openning a PR for preparing a new release.  Some
modules now have a REFERENCE.md file that also needs to be updated (by
running `rake reference`), and forgetting to do so will remained
unnoticed until `rake release` complain that the file is not up-to-date
(so after the release PR was reviewed and merged).

This PR move the `changelog` and `reference` tasks from each module's
Rakefile (under modulesync control), to the voxpupuli-release gem,
rename them to `release:porcelain:changelog` and
`release:porcelain:reference` to leave room for new `changelog` and
`reference` tasks indicating they are new deprecated, and recommand
running the new `release:prepare` task that runs them.

This is indented to help maintainers smoothly update their workflow and
provide a framework where additional tasks can be added if need be.
  • Loading branch information
smortex committed Jul 27, 2022
1 parent ae77328 commit 87facb4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lib/voxpupuli/release/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,59 @@
fail "Unable to find a CHANGELOG.md entry for the #{v} release."
end
end

desc "Prepare a release"
task "release:prepare" do
Rake::Task["release:porcelain:changelog"].invoke
Rake::Task["release:porcelain:reference"].invoke if File.exist?('REFERENCE.md')
end

require 'github_changelog_generator/task'
require 'puppet_blacksmith'
GitHubChangelogGenerator::RakeTask.new "release:porcelain:changelog" do |config|
metadata = Blacksmith::Modulefile.new
config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
config.user = metadata.metadata['name'].split(%r{[-/]}).first
config.user = 'voxpupuli' if config.user == "puppet"
config.project = metadata.metadata['name']
end

# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
require 'rbconfig'
if RbConfig::CONFIG['host_os'] =~ /linux/
task "release:porcelain:changelog" do
puts 'Fixing line endings...'
changelog_file = 'CHANGELOG.md'
changelog_txt = File.read(changelog_file)
new_contents = changelog_txt.gsub(%r{\r\n}, "\n")
File.open(changelog_file, "w") {|file| file.puts new_contents }
end
end

desc "Generate REFERENCE.md"
task "release:porcelain:reference", [:debug, :backtrace] do |t, args|
patterns = ''
Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace])
end

# For backward compatibility
task :changelog do
fail <<-ERROR
The "changelog" task is deprecated.
Prefer "release:prepare" which manage all pre-release steps, or directly run
the "release:porcelain:changelog" task.
ERROR
end

# For backward compatibility
task :reference do
fail <<-ERROR
The "reference" task is deprecated.
Prefer "release:prepare" which manage all pre-release steps, or directly run
the "release:porcelain:reference" task.
ERROR
end
1 change: 1 addition & 0 deletions voxpupuli-release.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }

# Runtime dependencies, but also probably dependencies of requiring projects
s.add_runtime_dependency 'github_changelog_generator', '>= 1.16.1'
s.add_runtime_dependency 'rake'
s.add_runtime_dependency 'puppet-blacksmith', '>= 4.0.0'
s.add_runtime_dependency 'puppet-strings', '>= 2.9.0'
Expand Down

0 comments on commit 87facb4

Please sign in to comment.