dpl 1.5.8.travis.336.1 → 1.5.8.travis.356.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTdlMGNjYTY4YzgyYmY5NWYxNjY0MDJiOTBjNTRjOTNkYTYxZjZhOA==
4
+ Yzk2YTk3YzcxZmUzNDQ5ODNlOGQxZGU0YTQ0MjQ3YzZiNjVjZjU5ZA==
5
5
  data.tar.gz: !binary |-
6
- ZjZjMzM1YTY5NTFmOWEyZmI4YjBhMWIwNGFmMjM0MGFiNGJjYWM5Zg==
6
+ NmQ4NzMwNjc2N2ExZWI3YzE0YTE0ZGFkMGU0NjM0N2E0OTRkOGE4Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWY0M2NiNzE3ZDdiY2JmMjA0NjMxZGJiMDA1ZjVkNTUyNzVkZWJjZWIzYjM4
10
- OWNhNDkzYjVhNzNkMzc2MDMxNjJlNjYyNjI0NTI5MDBmOGVkMzk2Mzg4M2Q3
11
- ZDg1Mjg0YjU1YjcyNmM5YzY2OGY2YmQyZjFhNGIzMDUzYzExYWI=
9
+ MjU0OTU3MDliNzBkNDJlMGI3OWIxYmIzZjgwODM4NjgwMDQ2YTg3YmFmZGEx
10
+ MDcxZjVjZGEwZmYzMTY4OWM4NDdhOGUyMmY2ZWM3ZmRlZmU1YTFiMTBkZjli
11
+ ZTlkMDZhMTEwMWJkYTgwMTRiYTBhNjA5OWM2N2I0MjI0YzY0YjQ=
12
12
  data.tar.gz: !binary |-
13
- MmYzY2NmOTNlNTkzNWNlMmY4YzU1NWZmNmU4ODQ2NjliNDZkZjNiM2U4Mjhk
14
- NzI1ZDc2ZmEyOGEyMDY1MmEyNWQ2NTExOTdlMDUwYjJkZTBjN2MyMWNhYTk4
15
- ZDcwNjdhNWQ1MmIwODAyZGRjOWEwMGFhYzE5OTBhMTVlOGRhOTQ=
13
+ MTc0MGZkOGI1ZDE3OGY2ZWVlNmI1YjMwMWZkMGRmMjYzOTgxZjg4YzdmZTNi
14
+ YTQwOGY0ODMxZWMxYzg4M2EwYmIyMzg4Y2NlMjJiMDAwMWE4NzIxZjBkZjhj
15
+ OTFmMzEwYzQ0NDg3NTNmZTAwMDQ4ODY4Nzk4NDJiMTdmNTkwYjY=
data/Gemfile CHANGED
@@ -31,3 +31,7 @@ end
31
31
  group :cloud_files do
32
32
  gem 'fog'
33
33
  end
34
+
35
+ group :releases do
36
+ gem 'octokit'
37
+ end
data/README.md CHANGED
@@ -20,6 +20,7 @@ Dpl supports the following providers:
20
20
  * [Rackspace Cloud Files](#rackspace-cloud-files)
21
21
  * [AWS OpsWorks](#opsworks)
22
22
  * [Modulus](#modulus)
23
+ * [Github Releases](#github-releases)
23
24
 
24
25
  ## Installation:
25
26
 
@@ -258,3 +259,21 @@ As a rule of thumb, you should switch to the Git strategy if you run into issues
258
259
  #### Examples:
259
260
 
260
261
  dpl --provider=cloudfiles --username=<username> --api-key=<api-key> --region=<region> --container=<container>
262
+
263
+ ### GitHub Releases:
264
+
265
+ #### Options:
266
+
267
+ * **api-key**: GitHub oauth token with `public_repo` or`repo` permission.
268
+ * **user**: GitHub username. Not necessary if `api-key` is used.
269
+ * **password**: GitHub Password. Not necessary if `api-key` is used.
270
+ * **repo**: GitHub Repo. Defaults to git repo's name.
271
+ * **file**: File to upload to GitHub Release.
272
+
273
+ #### GitHub Two Factor Authentication
274
+
275
+ For accounts using two factor authentication, you have to use an oauth token as a username and password will not work.
276
+
277
+ #### Examples:
278
+
279
+ dpl --provider=releases --api-key=<api-key> --file=build.tar.gz
data/lib/dpl/provider.rb CHANGED
@@ -21,6 +21,7 @@ module DPL
21
21
  autoload :CloudFiles, 'dpl/provider/cloud_files'
22
22
  autoload :OpsWorks, 'dpl/provider/ops_works'
23
23
  autoload :Modulus, 'dpl/provider/modulus'
24
+ autoload :Releases, 'dpl/provider/releases'
24
25
 
25
26
  def self.new(context, options)
26
27
  return super if self < Provider
@@ -0,0 +1,68 @@
1
+ module DPL
2
+ class Provider
3
+ class Releases < Provider
4
+ requires 'octokit'
5
+ requires 'mime-types'
6
+
7
+ def get_tag
8
+ `git describe --tags --exact-match 2>/dev/null`.chomp
9
+ end
10
+
11
+ def api
12
+ if options[:user] and options[:password]
13
+ @api ||= Octokit::Client.new(:login => options[:user], :password => options[:password])
14
+ else
15
+ @api ||= Octokit::Client.new(:access_token => option(:api_key))
16
+ end
17
+ end
18
+
19
+ def slug
20
+ options.fetch(:repo) { ENV['TRAVIS_REPO_SLUG'] }
21
+ end
22
+
23
+ def releases
24
+ @releases ||= api.releases(slug)
25
+ end
26
+
27
+ def user
28
+ user ||= api.user
29
+ end
30
+
31
+ def needs_key?
32
+ false
33
+ end
34
+
35
+ def check_app
36
+ end
37
+
38
+ def setup_auth
39
+ user.login
40
+ end
41
+
42
+ def check_auth
43
+ setup_auth
44
+ log "Logged in as #{user.name}"
45
+ end
46
+
47
+ def push_app
48
+ tag_matched = false
49
+
50
+ releases.each do |release|
51
+ if release.tag_name == get_tag
52
+ api.upload_asset(release.rels[:self].href, option(:file), {:content_type => MIME::Types.type_for(option(:file)).first.to_s})
53
+ tag_matched = true
54
+ end
55
+ end
56
+ unless tag_matched
57
+ log <<-EOS
58
+ This isn't a GitHub release, so nothing has been deployed. If you haven't already, please add the following to the 'deploy' section of your .travis.yml:
59
+
60
+ on:
61
+ tags: true
62
+ all_branches: true
63
+ EOS
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
Binary file
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/releases'
3
+ require 'octokit'
4
+
5
+ describe DPL::Provider::Releases do
6
+ subject :provider do
7
+ described_class.new(DummyContext.new, :api_key => '0123445789qwertyuiop0123445789qwertyuiop', :file => 'blah.txt')
8
+ end
9
+
10
+ describe :api do
11
+ example "With API key" do
12
+ api = double(:api)
13
+ ::Octokit::Client.should_receive(:new).with(:access_token => '0123445789qwertyuiop0123445789qwertyuiop').and_return(api)
14
+ provider.api.should be == api
15
+ end
16
+
17
+ example "With username and password" do
18
+ api = double(:api)
19
+ provider.options.update(:user => 'foo')
20
+ provider.options.update(:password => 'bar')
21
+
22
+ ::Octokit::Client.should_receive(:new).with(:login => 'foo', :password => 'bar').and_return(api)
23
+ provider.api.should be == api
24
+ end
25
+ end
26
+
27
+ describe :releases do
28
+ example "With ENV Slug" do
29
+ provider.stub(:slug).and_return("foo/bar")
30
+
31
+ provider.api.should_receive(:releases).with("foo/bar")
32
+ provider.releases
33
+ end
34
+
35
+ example "With repo option" do
36
+ provider.options.update(:repo => 'bar/foo')
37
+
38
+ provider.api.should_receive(:releases).with('bar/foo')
39
+ provider.releases
40
+ end
41
+ end
42
+
43
+ describe :needs_key? do
44
+ example do
45
+ provider.needs_key?.should == false
46
+ end
47
+ end
48
+
49
+ describe :check_auth do
50
+ example do
51
+ allow_message_expectations_on_nil
52
+ provider.stub(:user)
53
+ provider.stub(:setup_auth)
54
+ provider.user.should_receive(:name).and_return("foo")
55
+ provider.should_receive(:log).with("Logged in as foo")
56
+ provider.check_auth
57
+ end
58
+ end
59
+
60
+ describe :push_app do
61
+ example do
62
+ allow_message_expectations_on_nil
63
+ provider.stub(:releases).and_return([""])
64
+ provider.releases.map do |release|
65
+ release.stub(:tag_name).and_return("v0.0.0")
66
+ release.stub(:rels).and_return({:self => nil})
67
+ release.rels[:self].stub(:href)
68
+ end
69
+ provider.stub(:get_tag).and_return("v0.0.0")
70
+ provider.api.should_receive(:upload_asset)
71
+ provider.push_app
72
+ end
73
+ end
74
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.8.travis.336.1
4
+ version: 1.5.8.travis.356.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -102,12 +102,14 @@ files:
102
102
  - lib/dpl/provider/openshift.rb
103
103
  - lib/dpl/provider/ops_works.rb
104
104
  - lib/dpl/provider/pypi.rb
105
+ - lib/dpl/provider/releases.rb
105
106
  - lib/dpl/provider/rubygems.rb
106
107
  - lib/dpl/provider/s3.rb
107
108
  - lib/dpl/version.rb
108
109
  - notes/dotcloud.md
109
110
  - notes/engine_yard.md
110
111
  - notes/heroku.md
112
+ - setuptools-3.3.zip
111
113
  - spec/cli_spec.rb
112
114
  - spec/provider/appfog_spec.rb
113
115
  - spec/provider/cloud_files_spec.rb
@@ -122,6 +124,7 @@ files:
122
124
  - spec/provider/openshift_spec.rb
123
125
  - spec/provider/ops_works_spec.rb
124
126
  - spec/provider/pypi_spec.rb
127
+ - spec/provider/releases_spec.rb
125
128
  - spec/provider/rubygems_spec.rb
126
129
  - spec/provider/s3_spec.rb
127
130
  - spec/provider_spec.rb