-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The task is mostly copied from RuboCop. I somehow couldn't get this line to work: Rake::Task['update_cops_documentation'].invoke which is why we shell out instead: `bundle exec rake generate_cops_documentation`
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
inherit_from: .rubocop_todo.yml | ||
|
||
require: | ||
- rubocop-performance | ||
- rubocop-rake | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` | ||
# using RuboCop version 1.36.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
Rake/MethodDefinitionInTask: | ||
Exclude: | ||
- 'tasks/cut_release.rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ source 'https://rubygems.org' | |
|
||
gemspec | ||
|
||
gem 'bump' | ||
gem 'rack' | ||
gem 'rake' | ||
gem 'rspec', '~> 3.11' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bump' | ||
|
||
namespace :cut_release do | ||
def update_file(path) | ||
content = File.read(path) | ||
File.write(path, yield(content)) | ||
end | ||
|
||
%w[major minor patch pre].each do |release_type| | ||
desc "Cut a new #{release_type} release and update documents." | ||
task release_type do | ||
run(release_type) | ||
end | ||
end | ||
|
||
def version_sans_patch(version) | ||
version.split('.').take(2).join('.') | ||
end | ||
|
||
# Replace `<<next>>` (and variations) with version being cut. | ||
def update_cop_versions(version) | ||
update_file('config/default.yml') do |default| | ||
default.gsub(/['"]?<<\s*next\s*>>['"]?/i, | ||
"'#{version_sans_patch(version)}'") | ||
end | ||
RuboCop::ConfigLoader.default_configuration = nil # invalidate loaded conf | ||
end | ||
|
||
def update_docs(version) | ||
update_file('docs/antora.yml') do |antora_metadata| | ||
antora_metadata.sub('version: master', | ||
"version: '#{version_sans_patch(version)}'") | ||
end | ||
end | ||
|
||
def add_header_to_changelog(version) | ||
update_file('CHANGELOG.md') do |changelog| | ||
changelog.sub("## Master (Unreleased)\n\n", | ||
'\0' "## #{version} (#{Time.now.strftime('%F')})\n\n") | ||
end | ||
end | ||
|
||
def run(release_type) | ||
old_version = Bump::Bump.current | ||
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false) | ||
new_version = Bump::Bump.current | ||
|
||
update_cop_versions(new_version) | ||
`bundle exec rake generate_cops_documentation` | ||
update_docs(new_version) | ||
add_header_to_changelog(new_version) | ||
|
||
puts "Changed version from #{old_version} to #{new_version}." | ||
end | ||
end |