heroku_deployer 0.6.3 → 0.7

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: 4a2c55e980f08f9bcc0b41a4d9f5e60b263ff50f
4
- data.tar.gz: 2747881515b2bf19dd97da87196c1cadf340e477
3
+ metadata.gz: 2b37db385331039d22c8a8606c068690774e52e3
4
+ data.tar.gz: d83ad7799d516a0a07aecbc2f3d70507c833b59b
5
5
  SHA512:
6
- metadata.gz: cb84423805106808cc39c5fd132957b1e86288f7892515fa975ae02ef80473e28c934b773ce76beae68cebc9d14875604009b87134fba0090ae0042a9790b7db
7
- data.tar.gz: eed0db2d645213f641dbf10547e5c9bcc7319b98c1e6ebc9321f12a0b220c042b5eb1965b8146cb95caccc098ba40274e255f7946b41bdfb32fc6694f864db2e
6
+ metadata.gz: 577e8d776958ab6e9e02c54c68b12f14be2d398fb0b8b1c331a40aea665e8d77571b353ddad35b6f430feaeeacc527e9f2ab296ac645fe5b3dd87daa294c418e
7
+ data.tar.gz: 018b0dc7afd3c5cd3a67900a51e4aaa40c5fc60c0d229756307d8eaf9a0f160f2245bfaf1aca838a28c2e33b0e1f60a7441f660ec85cc5e9671ec16c5a81198a
@@ -1,5 +1,4 @@
1
- require 'heroku-api'
2
- require 'heroku/new_api'
1
+ require 'platform-api'
3
2
  require 'rendezvous'
4
3
 
5
4
  module Amitree
@@ -11,14 +10,21 @@ module Amitree
11
10
  end
12
11
 
13
12
  def initialize(api_key, staging_app_name, production_app_name)
14
- @heroku = Heroku::API.new(:api_key => api_key)
15
- # We need to use the new API (not currently supported by the heroku-api gem) for deploy_to_production
16
- @heroku_new = Heroku::NewAPI.new(:api_key => api_key)
13
+ @heroku = PlatformAPI.connect(api_key)
14
+ @heroku_no_cache = PlatformAPI.connect(api_key, cache: Moneta.new(:Null))
17
15
  @staging_app_name = staging_app_name
18
16
  @production_app_name = production_app_name
19
17
  @promoted_release_regexp = /Promote #{@staging_app_name} (v\d+)/
20
18
  end
21
19
 
20
+ def get_staging_commit(release)
21
+ @heroku.slug.info(@staging_app_name, release['slug']['id'])['commit']
22
+ end
23
+
24
+ def get_production_commit(release)
25
+ @heroku.slug.info(@production_app_name, release['slug']['id'])['commit']
26
+ end
27
+
22
28
  def current_production_release
23
29
  get_releases(@production_app_name)[-1]
24
30
  end
@@ -51,7 +57,7 @@ module Amitree
51
57
  slug = staging_slug(staging_release_name)
52
58
  puts "Deploying slug to production: #{slug}"
53
59
  unless options[:dry_run]
54
- @heroku_new.post_release(@production_app_name, {'slug' => slug, 'description' => "Promote #{@staging_app_name} #{staging_release_name}"})
60
+ @heroku.release.create(@production_app_name, {'slug' => slug, 'description' => "Promote #{@staging_app_name} #{staging_release_name}"})
55
61
  db_migrate_on_production(options)
56
62
  end
57
63
  end
@@ -60,8 +66,8 @@ module Amitree
60
66
  unless staging_release_name =~ /\Av(\d+)\z/
61
67
  raise Error.new "Unexpected release name: #{staging_release_name}"
62
68
  end
63
- result = @heroku_new.get_release(@staging_app_name, $1)
64
- result.body['slug']['id'] || raise(Error.new("Could not find slug in API response: #{result.inspect}"))
69
+ result = @heroku.release.info(@staging_app_name, $1)
70
+ result['slug']['id'] || raise(Error.new("Could not find slug in API response: #{result.inspect}"))
65
71
  end
66
72
 
67
73
  def db_migrate_on_production(options={}, attempts=0)
@@ -80,12 +86,14 @@ module Amitree
80
86
 
81
87
  private
82
88
  def get_releases(app_name)
83
- @heroku.get_releases(app_name).body
89
+ # Use our own cache because of https://github.com/heroku/platform-api/issues/16
90
+ @release_cache ||= {}
91
+ @release_cache[app_name] ||= @heroku_no_cache.release.list(app_name).to_a
84
92
  end
85
93
 
86
94
  def heroku_run(app_name, command)
87
95
  puts "Running command on #{app_name}: #{command}..."
88
- data = @heroku.post_ps(app_name, command, { attach: true }).body
96
+ data = @heroku.dyno.create(app_name, { command: command, attach: true })
89
97
  read, write = IO.pipe
90
98
  Rendezvous.start(url: data['rendezvous_url'], input: read)
91
99
  read.close
@@ -52,14 +52,14 @@ module Amitree
52
52
  result.production_promoted_from_staging = @heroku.promoted_from_staging?(result.production_release)
53
53
  staging_releases = @heroku.staging_releases_since(@heroku.staging_release_name(result.production_release))
54
54
 
55
- prod_commit = result.production_release['commit']
56
- puts "Production release is #{prod_commit}" if options[:verbose]
55
+ prod_commit = @heroku.get_production_commit(result.production_release)
56
+ puts "Production release is #{prod_commit_full}" if options[:verbose]
57
57
 
58
58
  result.stories = stories_worked_on_between(prod_commit, 'HEAD')
59
59
  all_stories = Hash[result.stories.map{|story| [story.id, story]}]
60
60
 
61
61
  staging_releases.reverse.each do |staging_release|
62
- staging_commit = staging_release['commit']
62
+ staging_commit = @heroku.get_staging_commit(staging_release)
63
63
  stories = all_stories.values_at(*@git.stories_worked_on_between(prod_commit, staging_commit)).compact
64
64
  story_ids = stories.map(&:id)
65
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Wargnier
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-22 00:00:00.000000000 Z
12
+ date: 2014-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -40,19 +40,19 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.7.1
42
42
  - !ruby/object:Gem::Dependency
43
- name: heroku-api
43
+ name: platform-api
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 0.3.17
48
+ version: 0.2.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.3.17
55
+ version: 0.2.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rendezvous
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -91,7 +91,6 @@ files:
91
91
  - lib/amitree/git_client.rb
92
92
  - lib/amitree/heroku_client.rb
93
93
  - lib/amitree/heroku_deployer.rb
94
- - lib/heroku/new_api.rb
95
94
  homepage: http://rubygems.org/gems/heroku_deployer
96
95
  licenses:
97
96
  - MIT
@@ -1,21 +0,0 @@
1
- require 'multi_json'
2
-
3
- module Heroku
4
- class NewAPI < API
5
- def initialize(options={})
6
- options[:headers] ||= {}
7
- options[:headers]['Accept'] = 'application/vnd.heroku+json; version=3'
8
- super(options)
9
- end
10
-
11
- # POST /apps/:app/releases/:release
12
- def post_release(app, query={})
13
- request(
14
- :expects => 201,
15
- :method => :post,
16
- :path => "/apps/#{app}/releases",
17
- :body => MultiJson.dump(query)
18
- )
19
- end
20
- end
21
- end