-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rakefile
83 lines (66 loc) · 2.46 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require "dotenv/load"
require "rspec/core/rake_task"
require "rubocop/rake_task"
require "tasks/distribution"
require "sprockets"
RSpec::Core::RakeTask.new(:spec)
namespace :lint do
desc "Run RuboCop autocorrect"
task :autocorrect do
RuboCop::RakeTask.new(:rubocop)
Rake::Task["rubocop:auto_correct"].invoke
end
end
namespace :assets do
desc "Package JS and CSS assets to /dist for external use."
task :package do
add_jquery_to_path
Distribution.new
puts "Assets generated to /dist"
end
end
desc "Commit version and changelog"
task :release, [:version_bump] do |_t, args|
version_bump = args[:version_bump]
unless version_bump
puts "Pass a version [major|minor|patch|pre|release] or a given version number [x.x.x]:"
puts "$ bundle exec rake release[VERSION_BUMP]"
exit(1)
end
if %w[major minor].include?(version_bump)
puts "\n== Reviewing documentation =="
puts "This is a #{version_bump} release. Have you updated MIGRATING.md? (y/n)"
input = $stdin.gets.strip.downcase
unless input == "y"
puts "Please update MIGRATING.md, commit the changes, then re-run the release command."
exit(1)
end
end
execute_release_steps(version_bump)
end
def execute_release_steps(version_bump)
puts "\n== Bumping version number =="
system!("gem bump --no-commit --version #{version_bump}")
puts "\n== Reloading Cfa::Styleguide::VERSION"
load File.expand_path("lib/cfa/styleguide/version.rb", __dir__)
new_version = Cfa::Styleguide::VERSION
puts "\n== Updating Changelog =="
system!(ENV, "bundle exec github_changelog_generator --user codeforamerica --project honeycrisp-gem --future-release v#{new_version} --exclude-labels discussion,wontfix")
puts "\n== Updating Gemfile.lock version =="
system!("bundle install")
puts "\n== Creating git commit =="
system!("git add lib/cfa/styleguide/version.rb CHANGELOG.md Gemfile.lock")
system!("git commit -m \"Release honeycrisp-gem v#{new_version}\"")
system!("git tag v#{new_version}")
puts "\n== Next steps =="
puts " Push commit and tag to Github:"
puts " $ git push origin && git push origin --tags"
end
def system!(*args)
system(*args) || abort("\n== Command #{args.join(' ')} failed ==")
end
def add_jquery_to_path
jquery_path = Dir.entries("#{Gem.paths.home}/gems/").detect { |dir| dir.match(/jquery-rails(.*)/) }
$LOAD_PATH.unshift("#{Gem.paths.home}/gems/#{jquery_path}/vendor/") if jquery_path
end
task default: %w[lint:autocorrect spec]