update.rb 974 Bytes
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2 3 4
root_path = File.expand_path(File.dirname(__FILE__))
require File.join(root_path, "lib", "color")
include Color

gitlabhq's avatar
gitlabhq committed
5 6 7 8
def version
  File.read("VERSION")
end

gitlabhq's avatar
gitlabhq committed
9 10 11 12 13 14 15 16 17 18
# 
# ruby ./update.rb development # or test or production (default)
#
envs = ["production", "test", "development"]
env = if envs.include?(ARGV[0])
        ARGV[0]
      else
        "production"
      end

gitlabhq's avatar
gitlabhq committed
19 20 21
puts yellow "== RAILS ENV | #{env}"
current_version = version
puts yellow "Your version is #{current_version}"
gitlabhq's avatar
gitlabhq committed
22 23
puts yellow "Check for new version: $ git pull origin 1x"
`git pull origin 1x` # pull from origin
gitlabhq's avatar
gitlabhq committed
24

gitlabhq's avatar
gitlabhq committed
25 26 27 28 29
# latest version
if version == current_version
  puts yellow "You have a latest version"
else
  puts green "Update to #{version}"
gitlabhq's avatar
gitlabhq committed
30 31 32

`bundle install`

gitlabhq's avatar
gitlabhq committed
33 34 35 36 37
  # migrate db
if env == "development"
`bundle exec rake db:migrate RAILS_ENV=development`
`bundle exec rake db:migrate RAILS_ENV=test`
else
gitlabhq's avatar
gitlabhq committed
38
`bundle exec rake db:migrate RAILS_ENV=#{env}`
gitlabhq's avatar
gitlabhq committed
39 40 41 42
end

  puts green "== Done! Now you can start/restart server"
end
gitlabhq's avatar
gitlabhq committed
43 44