middleman/Rakefile

81 lines
2.3 KiB
Ruby
Raw Normal View History

require 'rubygems' unless defined?(Gem)
# require 'fileutils' unless defined?(FileUtils)
require 'rake'
2011-12-30 04:52:00 +01:00
require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__)
ROOT = File.expand_path(File.dirname(__FILE__))
GEM_NAME = 'middleman'
2013-10-20 00:59:12 +02:00
middleman_gems = %w(middleman-core middleman)
2011-12-30 04:52:00 +01:00
GEM_PATHS = middleman_gems.freeze
def sh_rake(command)
sh "#{Gem.ruby} -S rake #{command}", :verbose => true
end
desc 'Displays the current version'
2011-12-30 04:52:00 +01:00
task :version do
2014-04-29 01:02:18 +02:00
puts "Current version: #{Middleman::VERSION}"
2011-12-30 04:52:00 +01:00
end
desc 'Bumps the version number based on given version'
2014-04-29 01:02:18 +02:00
task :bump, [:version] do |_, args|
raise 'Please specify version=x.x.x !' unless args.version
2011-12-30 04:52:00 +01:00
version_path = File.dirname(__FILE__) + '/middleman-core/lib/middleman-core/version.rb'
version_text = File.read(version_path).sub(/VERSION = '[\d\.\w]+'/, "VERSION = '#{args.version}'")
2014-04-29 01:02:18 +02:00
puts "Updating Middleman to version #{args.version}"
2011-12-30 04:52:00 +01:00
File.open(version_path, 'w') { |f| f.write version_text }
sh 'git commit -a -m "Bumped version to %s"' % args.version
end
desc 'Executes a fresh install removing all middleman version and then reinstall all gems'
2011-12-30 04:52:00 +01:00
task :fresh => [:uninstall, :install, :clean]
desc 'Pushes repository to GitHub'
2011-12-30 04:52:00 +01:00
task :push do
2014-04-29 01:02:18 +02:00
puts 'Pushing to github...'
2011-12-30 04:52:00 +01:00
sh "git tag v#{Middleman::VERSION}"
sh 'git push origin master'
2011-12-30 04:52:00 +01:00
sh "git push origin v#{Middleman::VERSION}"
end
desc 'Release all middleman gems'
2011-12-30 04:52:00 +01:00
task :publish => :push do
2014-04-29 01:02:18 +02:00
puts 'Pushing to rubygems...'
2011-12-30 04:52:00 +01:00
GEM_PATHS.each do |dir|
Dir.chdir(dir) { sh_rake('release') }
2011-12-30 04:52:00 +01:00
end
Rake::Task['clean'].invoke
2011-12-30 04:52:00 +01:00
end
desc 'Generate documentation for all middleman gems'
2012-05-02 20:13:06 +02:00
task :doc do
GEM_PATHS.each do |g|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" }
2012-05-02 20:13:06 +02:00
end
end
desc 'Run tests for all middleman gems'
task :test do
2011-12-30 04:52:00 +01:00
GEM_PATHS.each do |g|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
end
end
desc 'Run specs for all middleman gems'
task :spec do
GEM_PATHS.each do |g|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake spec" }
end
end
2014-04-29 01:02:18 +02:00
require 'rubocop/rake_task'
desc 'Run RuboCop to check code consistency'
Rubocop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = false
2013-05-24 00:59:26 +02:00
end
desc 'Run tests for all middleman gems'
task :default => :test