1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/Rakefile
2014-04-28 16:02:18 -07:00

80 lines
2.3 KiB
Ruby

require 'rubygems' unless defined?(Gem)
# require 'fileutils' unless defined?(FileUtils)
require 'rake'
require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__)
ROOT = File.expand_path(File.dirname(__FILE__))
GEM_NAME = 'middleman'
middleman_gems = %w(middleman-core middleman)
GEM_PATHS = middleman_gems.freeze
def sh_rake(command)
sh "#{Gem.ruby} -S rake #{command}", :verbose => true
end
desc 'Displays the current version'
task :version do
puts "Current version: #{Middleman::VERSION}"
end
desc 'Bumps the version number based on given version'
task :bump, [:version] do |_, args|
raise 'Please specify version=x.x.x !' unless args.version
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}'")
puts "Updating Middleman to version #{args.version}"
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'
task :fresh => [:uninstall, :install, :clean]
desc 'Pushes repository to GitHub'
task :push do
puts 'Pushing to github...'
sh "git tag v#{Middleman::VERSION}"
sh 'git push origin master'
sh "git push origin v#{Middleman::VERSION}"
end
desc 'Release all middleman gems'
task :publish => :push do
puts 'Pushing to rubygems...'
GEM_PATHS.each do |dir|
Dir.chdir(dir) { sh_rake('release') }
end
Rake::Task['clean'].invoke
end
desc 'Generate documentation for all middleman gems'
task :doc do
GEM_PATHS.each do |g|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" }
end
end
desc 'Run tests for all middleman gems'
task :test do
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
require 'rubocop/rake_task'
desc 'Run RuboCop to check code consistency'
Rubocop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = false
end
desc 'Run tests for all middleman gems'
task :default => :test