capistrano-s3 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02a173c70a3b3da2d285fed463f5e75b6252705d
4
- data.tar.gz: 9423d2d35159919b6ccd274d142c258217fe0ad8
3
+ metadata.gz: 7181c1cd58ffcacd370bc1801a4a1de156b60490
4
+ data.tar.gz: 48c6ab3151aa29bc96df90bcbb50bbb66340f2f7
5
5
  SHA512:
6
- metadata.gz: 540baac23fcd625598b9f3324e0a5c80360fc0b712cf482b067ca4bd2eb8b1334bf8e2fc65209cd85ceeb22c2f8dee1c9dbc174c48e4996be75a5cd151a4aed6
7
- data.tar.gz: 09ec556aa3df667487e68d1c00b14a77a40b1a7e03c5305092d3eaf836a399431610779aaf8a3f17c6a7c056bb2432fe77433ba16c9ee4d5fc12d50b6c7d3b90
6
+ metadata.gz: df7c91285663a990bef6c758a9119b11fde17c6fc6e82b01b753c62925331f68f757d8132338aae56787d87e22b3377c8a566d4e5db2550228eeaab87986a21f
7
+ data.tar.gz: eb45abf3f729d1f3c92245c2e76bc505651ffd5eb94dc4ab2c6bb591a12511570cb870c9f97a78feb8918a862d40dd55bb507f4ce8fb38eb79a1cf4f12b48b71
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.travis.yml CHANGED
@@ -1,13 +1,14 @@
1
1
  language: ruby
2
+ dist: trusty
2
3
  bundler_args: --without debug release
3
4
  before_install:
4
- - gem install bundler
5
+ - ruby -v | (grep -v "rubinius" && gem install bundler) || echo 0
5
6
  rvm:
6
- - 2.1.10
7
- - 2.2.5
8
- - 2.3.1
9
- - rbx-2
10
- - jruby-9.0.5.0
7
+ - 2.2.6
8
+ - 2.3.3
9
+ - 2.4.0
10
+ - rbx-3.69
11
+ - jruby-9.1.5.0
11
12
  - jruby-head
12
13
  - ruby-head
13
14
  matrix:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.1.0
4
+
5
+ Feature : Add support for Cloudfront invalidations (#29) @exoszajzbuk
6
+
3
7
  ## v1.0.0
4
8
 
5
9
  Major change : drop support for ruby < 2.1
data/README.md CHANGED
@@ -130,6 +130,15 @@ Just add to your configuration:
130
130
  set :only_gzip, true
131
131
  ```
132
132
 
133
+ ### CloudFront invalidation
134
+
135
+ If you set a CloudFront distribution ID (not the URL!) and an array of paths, capistrano-s3 will post an invalidation request. CloudFront supports wildcard invalidations. For example:
136
+
137
+ ```ruby
138
+ set :distribution_id, "CHANGETHIS"
139
+ set :invalidations, [ "/index.html", "/assets/*" ]
140
+ ```
141
+
133
142
  ## Example of usage
134
143
 
135
144
  Our Ruby stack for static websites:
@@ -6,7 +6,8 @@ module Capistrano
6
6
  :bucket_write_options => { :acl => :public_read },
7
7
  :s3_endpoint => "s3.amazonaws.com",
8
8
  :redirect_options => {},
9
- :only_gzip => false
9
+ :only_gzip => false,
10
+ :invalidations => []
10
11
  }
11
12
 
12
13
  def self.populate(context, set_method)
@@ -7,8 +7,9 @@ module Capistrano
7
7
  module Publisher
8
8
  LAST_PUBLISHED_FILE = '.last_published'
9
9
 
10
- def self.publish!(s3_endpoint, key, secret, bucket, source, only_gzip, extra_options)
10
+ def self.publish!(s3_endpoint, key, secret, bucket, source, distribution_id, invalidations, only_gzip, extra_options)
11
11
  s3 = self.establish_s3_client_connection!(s3_endpoint, key, secret)
12
+ updated = false
12
13
 
13
14
  self.files(source).each do |file|
14
15
  if !File.directory?(file)
@@ -22,6 +23,22 @@ module Capistrano
22
23
  end
23
24
  end
24
25
 
26
+ # invalidate CloudFront distribution if needed
27
+ if distribution_id && !invalidations.empty?
28
+ cf = self.establish_cf_client_connection!(key, secret)
29
+
30
+ cf.create_invalidation({
31
+ :distribution_id => distribution_id,
32
+ :invalidation_batch => {
33
+ :paths => {
34
+ :quantity => invalidations.count,
35
+ :items => invalidations
36
+ },
37
+ :caller_reference => SecureRandom.hex
38
+ }
39
+ })
40
+ end
41
+
25
42
  FileUtils.touch(LAST_PUBLISHED_FILE)
26
43
  end
27
44
 
@@ -45,6 +62,10 @@ module Capistrano
45
62
  )
46
63
  end
47
64
 
65
+ def self.establish_cf_client_connection!(key, secret)
66
+ self.establish_connection!(AWS::CloudFront::Client, nil, key, secret)
67
+ end
68
+
48
69
  def self.establish_s3_client_connection!(s3_endpoint, key, secret)
49
70
  self.establish_connection!(AWS::S3::Client, s3_endpoint, key, secret)
50
71
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module S3
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ module Capistrano
18
18
  task :upload_files do
19
19
  extra_options = { :write => bucket_write_options, :redirect => redirect_options }
20
20
  S3::Publisher.publish!(s3_endpoint, access_key_id, secret_access_key,
21
- bucket, deployment_path, only_gzip, extra_options)
21
+ bucket, deployment_path, distribution_id, invalidations, only_gzip, extra_options)
22
22
  end
23
23
  end
24
24
 
@@ -15,7 +15,7 @@ namespace :deploy do
15
15
  task :upload_files do
16
16
  extra_options = { :write => fetch(:bucket_write_options), :redirect => fetch(:redirect_options) }
17
17
  Capistrano::S3::Publisher.publish!(fetch(:s3_endpoint), fetch(:access_key_id), fetch(:secret_access_key),
18
- fetch(:bucket), fetch(:deployment_path), fetch(:only_gzip), extra_options)
18
+ fetch(:bucket), fetch(:deployment_path), fetch(:distribution_id), fetch(:invalidations), fetch(:only_gzip), extra_options)
19
19
  end
20
20
  end
21
21
 
@@ -10,16 +10,17 @@ describe Capistrano::S3::Publisher do
10
10
  context "on publish!" do
11
11
  it "publish all files" do
12
12
  AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(8)
13
+ AWS::CloudFront::Client::V20141106.any_instance.expects(:create_invalidation).once
13
14
 
14
15
  path = File.join(@root, 'sample')
15
- Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, false, {})
16
+ Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', ['*'], false, {})
16
17
  end
17
18
 
18
19
  it "publish only gzip files when option is enabled" do
19
20
  AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(4)
20
21
 
21
22
  path = File.join(@root, 'sample')
22
- Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, true, {})
23
+ Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], true, {})
23
24
  end
24
25
  end
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Philippe Doyle
@@ -36,7 +36,7 @@ cert_chain:
36
36
  t/JsZnAlWYkJIees2SFV5X/t34oeMu04yY2u9y2YBqKovR97m5YF7zqgx0JODV0x
37
37
  ytwUJvEjznBnJV4OoDE=
38
38
  -----END CERTIFICATE-----
39
- date: 2016-09-23 00:00:00.000000000 Z
39
+ date: 2017-01-24 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: aws-sdk
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  version: '0'
221
221
  requirements: []
222
222
  rubyforge_project:
223
- rubygems_version: 2.5.1
223
+ rubygems_version: 2.5.2
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Build and deploy a static website to Amazon S3
metadata.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- �;օ8�ݓ�>�OÀ�\�g"�`����y�%g׊рKRo�o�l'ཏ��?h��ח��O �ߩR�R0@J�,�ܜ>������3%��F�#�b ��ƾ��+�h#��^jc+jGX21��0�г��3H�V��ĺw=�pl�g��S��EO�4�LPo�7�Vi5%��.��#�&\�V �r�]c�S%�9�B$ɥ����Is�Ic�.2���
2
- \8�+���ԛy��
1
+ d�����$7k,���"y:B
2
+ ) Qҧ��V� G>�jE��*�T�*ǽ�#P=�"3��/�L��{���+؆����j�+x�� ]�%6�3|��� N��wX�Z/���w
3
+ �D0��T�P������1u%hR 9`����q���j���;`qՄ0�ݠ��V{�� �*: =����Ex5���8������V�W�"��[Kz"I��7���T�ѩ���4cPcB��|k�>�C�OCa�h��ѽsU