2011-10-14 15:40:41 +02:00
|
|
|
root_path = File.expand_path(File.dirname(__FILE__))
|
|
|
|
require File.join(root_path, "lib", "color")
|
|
|
|
include Color
|
|
|
|
|
2011-10-17 17:45:31 +02:00
|
|
|
def version
|
|
|
|
File.read("VERSION")
|
|
|
|
end
|
|
|
|
|
2011-10-14 15:40:41 +02:00
|
|
|
#
|
|
|
|
# ruby ./update.rb development # or test or production (default)
|
|
|
|
#
|
|
|
|
envs = ["production", "test", "development"]
|
|
|
|
env = if envs.include?(ARGV[0])
|
|
|
|
ARGV[0]
|
|
|
|
else
|
|
|
|
"production"
|
|
|
|
end
|
|
|
|
|
2011-10-17 17:45:31 +02:00
|
|
|
puts yellow "== RAILS ENV | #{env}"
|
|
|
|
current_version = version
|
|
|
|
puts yellow "Your version is #{current_version}"
|
2011-10-21 08:58:28 +02:00
|
|
|
puts yellow "Check for new version: $ git pull origin 1x"
|
|
|
|
`git pull origin 1x` # pull from origin
|
2011-10-14 15:40:41 +02:00
|
|
|
|
2011-10-17 17:45:31 +02:00
|
|
|
# latest version
|
|
|
|
if version == current_version
|
|
|
|
puts yellow "You have a latest version"
|
|
|
|
else
|
|
|
|
puts green "Update to #{version}"
|
2011-10-14 15:40:41 +02:00
|
|
|
|
|
|
|
`bundle install`
|
|
|
|
|
2011-10-17 17:45:31 +02:00
|
|
|
# migrate db
|
|
|
|
if env == "development"
|
|
|
|
`bundle exec rake db:migrate RAILS_ENV=development`
|
|
|
|
`bundle exec rake db:migrate RAILS_ENV=test`
|
|
|
|
else
|
2011-10-14 15:40:41 +02:00
|
|
|
`bundle exec rake db:migrate RAILS_ENV=#{env}`
|
2011-10-17 17:45:31 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
puts green "== Done! Now you can start/restart server"
|
|
|
|
end
|
2011-10-14 15:40:41 +02:00
|
|
|
|
|
|
|
|