heroku-tagged-deploy 0.0.2.8 → 0.0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a5787c18e48b8d457c96709a3e6f4ac554057cc
4
- data.tar.gz: 8d2ea91fe57942ef060bad8c1ff3f7228b1fe65e
3
+ metadata.gz: ba946db40d2aaeb1be1cbdb4a2e0cf9e01e5e592
4
+ data.tar.gz: 29f0bfcecf76a2ab5bf0ca0231ba40a186ff92da
5
5
  SHA512:
6
- metadata.gz: 02400b2f96c1fcc4c3f5702dd27303e7707e1f850ce9ff3660a382c18c35244954caabd3c496caf24e0f26634c9a8aa895da5abe47abaee2fab4cfe1dbda32f0
7
- data.tar.gz: f7406e88b8b8fa0cbd96f29f5832714f231cfd02e315f5d48453a0591f1d75b4bf9286e56ca8646a52a668a903e25c5972e1a150548f28451869a97fad87d632
6
+ metadata.gz: 3076b8a457f9222f3b32f1d43c3027c0436ce2707b81963914c593466dd8ee74947dd07fe9af07769198066e95a7064105138c20f526099e54b71631a8b1dce3
7
+ data.tar.gz: 6e5fead9de92cc96b0d04bde53802f58f6232c17e96ea5a1a6c788b84877de2719102f77ab1bec726809e3ee7c90e796d3e4872fbd83ad00276ed2f6be682d3f
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "heroku_san", "~> 4.3.2"
21
+ # spec.add_runtime_dependency "heroku_san", "~> 4.3.2"
22
22
  spec.add_runtime_dependency 'auto_tagger', '~> 0.2.8'
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.10"
@@ -1,7 +1,7 @@
1
1
  module Heroku
2
2
  module Tagged
3
3
  module Deploy
4
- VERSION = "0.0.2.8"
4
+ VERSION = "0.0.6.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,73 +1,106 @@
1
1
  module HerokuSan
2
2
  module Deploy
3
3
  class Tagged < Base
4
-
5
4
  def get_changes
6
- puts "Getting current tags..."
7
- sh "git fetch --tags"
8
- puts "[#{@stage.name}] Fetching current state."
9
- sh "git fetch #{@stage.name}"
10
- puts "[#{@stage.name}] Deploying..."
5
+ say 'Getting current tags...'
6
+ `git fetch --tags`
7
+ say 'Fetching current state.'
8
+ `git fetch #{@stage.name}`
11
9
  previous_sha_commit = `git rev-parse HEAD`.strip
12
- puts "[#{@stage.name}] Deploying these changes:"
10
+ say 'Deploying these changes:'
13
11
  puts `git log --pretty=format:"* %s" #{@stage.name}/master..#{previous_sha_commit}`
14
- puts ""
15
12
  @file_changes = `git diff --name-only #{previous_sha_commit} #{@stage.name}/master`
16
13
  end
17
14
 
18
15
  def enable_maintenance_if_needed
19
- if @file_changes.index("db/migrate") || @file_changes.index("db/seeds.rb")
20
- puts "[#{@stage.name}] Migrations found -- enabling maintenance mode..."
21
- @stage.maintenance(:on)
16
+ if @file_changes.index('db/migrate') || @file_changes.index('db/seeds.rb')
17
+ say 'Migrations found -- enabling maintenance mode...'
18
+ heroku("maintenance:on -a #{@stage.app}")
19
+ end
20
+ end
21
+
22
+ def deploying_assets?
23
+ if @file_changes.index('app/assets')
24
+ true
25
+ else
26
+ false
22
27
  end
23
28
  end
24
29
 
25
30
  def post_changes
26
- if @file_changes.index("db/migrate")
27
- puts "[#{@stage.name}] Running migrations, as there are new ones added."
28
- @stage.migrate
31
+ if @file_changes.index('db/migrate')
32
+ say 'Running migrations, as there are new ones added.'
33
+ heroku("run rake db:migrate -a #{@stage.app}")
29
34
  end
30
- if @file_changes.index("db/seeds.rb")
31
- puts "[#{@stage.name}] It looks like you adjusted or created the seeds.rb file."
32
- puts "[#{@stage.name}] Running the rake db:seed command now..."
33
- @stage.run('rake db:seed')
35
+ if @file_changes.index('db/seeds.rb')
36
+ say 'It looks like you adjusted or created the seeds.rb file.'
37
+ say 'Running the rake db:seed command now...'
38
+ heroku("run rake db:seed -a #{@stage.app}")
34
39
  end
35
- if @file_changes.index("db/migrate") || @file_changes.index("db/seeds.rb")
36
- puts "[#{@stage.name}] Disabling the maintenance mode."
37
- @stage.maintenance(:off)
38
- puts "[#{@stage.name}] Restarting..."
39
- @stage.restart
40
+ if @file_changes.index('db/migrate') || @file_changes.index('db/seeds.rb')
41
+ say 'Disabling the maintenance mode.'
42
+ heroku("maintenance:off -a #{@stage.app}")
43
+ say 'Restarting...'
44
+ heroku("restart -a #{@stage.app}")
40
45
  end
41
46
  end
42
47
 
43
48
  def precompile_assets
44
- sh 'rake RAILS_ENV=production RAILS_GROUP=assets assets:precompile'
45
- sh 'rake RAILS_GROUP=assets assets:clean_expired'
49
+ `rake RAILS_ENV=production RAILS_GROUP=assets assets:precompile`
50
+ `rake assets:clean_expired` if in_gemfile?('turbo-sprockets-rails3')
46
51
  if system('git diff --cached --exit-code') == false || system('git diff --exit-code') == false
47
- sh 'git add -A .'
48
- sh 'git gc'
49
- sh "git commit -m 'assets precompiled'"
50
- sh 'git push'
52
+ `git add -A .`
53
+ `git gc`
54
+ `git commit -m 'assets precompiled'`
55
+ `git push`
51
56
  else
52
- puts "No assets changed, no extra commit needed."
57
+ say 'No assets changed, no extra commit needed.'
53
58
  end
54
59
  end
55
60
 
61
+ def say(text)
62
+ puts "[#{Time.now.strftime('%H:%M:%S')}][#{@stage.name}] #{text}"
63
+ end
64
+
56
65
  def deploy
66
+ get_changes
67
+ say 'Checking for precompiled assets'
57
68
  if File.exist?(::Rails.root.join('public/assets/manifest.yml'))
58
- precompile_assets
69
+ say 'Found manifest.yml. Precompile assets.'
70
+ say 'Checking if we need to precompile'
71
+ if deploying_assets?
72
+ say 'Deploying new assets, precompiling...'
73
+ precompile_assets
74
+ else
75
+ say 'Not deploying new assets, skipped precompile.'
76
+ end
59
77
  end
60
78
 
61
- get_changes
62
79
  enable_maintenance_if_needed
63
-
80
+
64
81
  # Do the deploy
65
82
  super
66
-
83
+
67
84
  post_changes
68
85
 
69
86
  @stage.tag_repo
87
+
88
+ say 'Warming up the Heroku dynos'
89
+ sh "curl -o /dev/null http://#{@stage.app}.herokuapp.com"
90
+ end
91
+
92
+ private
93
+
94
+ def in_gemfile?(reg)
95
+ content = File.read(::Rails.root.join('Gemfile'))
96
+
97
+ !content.index(reg).nil?
98
+ end
99
+
100
+ # Executes a command in the Heroku Toolbelt
101
+ def heroku(command)
102
+ system("GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}")
70
103
  end
71
104
  end
72
105
  end
73
- end
106
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-tagged-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.8
4
+ version: 0.0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Westerink
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: heroku_san
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.3.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.3.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: auto_tagger
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
112
  version: '0'
127
113
  requirements: []
128
114
  rubyforge_project:
129
- rubygems_version: 2.4.5.1
115
+ rubygems_version: 2.6.11
130
116
  signing_key:
131
117
  specification_version: 4
132
118
  summary: Have a deploy be tagged with the stage name and a date