gitlab-org--gitlab-foss/update.rb

45 lines
968 B
Ruby
Raw Normal View History

2011-10-14 09:40:41 -04:00
root_path = File.expand_path(File.dirname(__FILE__))
require File.join(root_path, "lib", "color")
include Color
2011-10-17 11:45:31 -04:00
def version
File.read("VERSION")
end
2011-10-14 09:40:41 -04: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 11:45:31 -04:00
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
2011-10-14 09:40:41 -04:00
2011-10-17 11:45:31 -04:00
# latest version
if version == current_version
puts yellow "You have a latest version"
else
puts green "Update to #{version}"
2011-10-14 09:40:41 -04:00
`bundle install`
2011-10-17 11:45:31 -04: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 09:40:41 -04:00
`bundle exec rake db:migrate RAILS_ENV=#{env}`
2011-10-17 11:45:31 -04:00
end
puts green "== Done! Now you can start/restart server"
end
2011-10-14 09:40:41 -04:00