Commit add45eb8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

update.rb

parent a953e459
...@@ -11,6 +11,10 @@ module Color ...@@ -11,6 +11,10 @@ module Color
colorize(text, "32m") colorize(text, "32m")
end end
def yellow(text)
colorize(text, "93m")
end
def command(string) def command(string)
`#{string}` `#{string}`
if $?.to_i > 0 if $?.to_i > 0
......
...@@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__)) ...@@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__))
require File.join(root_path, "lib", "color") require File.join(root_path, "lib", "color")
include Color include Color
def version
File.read("VERSION")
end
# #
# ruby ./update.rb development # or test or production (default) # ruby ./update.rb development # or test or production (default)
# #
...@@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0]) ...@@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0])
"production" "production"
end end
puts green " == Update for ENV=#{env}" puts yellow "== RAILS ENV | #{env}"
current_version = version
puts yellow "Your version is #{current_version}"
puts yellow "Check for new version: $ git pull origin"
`git pull origin` # pull from origin
# pull from github # latest version
`git pull` if version == current_version
puts yellow "You have a latest version"
else
puts green "Update to #{version}"
`bundle install` `bundle install`
# migrate db # migrate db
if env == "development"
`bundle exec rake db:migrate RAILS_ENV=development`
`bundle exec rake db:migrate RAILS_ENV=test`
else
`bundle exec rake db:migrate RAILS_ENV=#{env}` `bundle exec rake db:migrate RAILS_ENV=#{env}`
end
puts green "== Done! Now you can start/restart server"
end
puts green " == Done! Now you can start/restart server"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment