octopress-deploy 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +2 -1
- data/lib/octopress-deploy/s3.rb +30 -3
- data/lib/octopress-deploy/version.rb +1 -1
- data/octopress-deploy.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf29f35bfa57acc33ee25af7d0f5c9b5adcadb2
|
4
|
+
data.tar.gz: f085e982084365aeef29b3ca26276f4d440478bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 491ff56f994ec6f573776df8474162158ea1dc27b801e1296c2be0cb89780854b2eb4a644baa0995c3f28078f148db3c9dfe4ac7bcbd9eba01ca6441e1f4ed71
|
7
|
+
data.tar.gz: ff49d3b5e4469e5d4c1937cc7cc4309309ef857f1d7505fa158477e023591bdab921dc82683c653c3a79afc43b540042d0930e4c4dde424288ca3614cb1ef4c1
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### 1.0
|
3
|
+
### 1.2.0 - 2015-03-07
|
4
|
+
|
5
|
+
- Added Support for Cloudfront invalidation [#49](https://github.com/octopress/deploy/pull/49)
|
6
|
+
|
7
|
+
### 1.1.0 - 2015-02-06
|
4
8
|
|
5
9
|
- Added incremental uploads to S3. [#46](https://github.com/octopress/deploy/pull/46)
|
6
10
|
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ Mainly you'd do this if you're troubleshooting deployment and you want to see if
|
|
73
73
|
|
74
74
|
## Amazon S3 Deployment Configuration
|
75
75
|
|
76
|
-
To deploy with Amazon S3 you will need to install the [aws-sdk gem](https://rubygems.org/gems/aws-sdk).
|
76
|
+
To deploy with Amazon S3 you will need to install the [aws-sdk-v1 gem](https://rubygems.org/gems/aws-sdk-v1).
|
77
77
|
|
78
78
|
Important: when using S3, you must add your `_deploy.yml` to your .gitignore to prevent accidentally sharing
|
79
79
|
account access information.
|
@@ -85,6 +85,7 @@ account access information.
|
|
85
85
|
| `bucket_name` | S3 bucket name | |
|
86
86
|
| `access_key_id` | AWS access key | |
|
87
87
|
| `secret_access_key` | AWS secret key | |
|
88
|
+
| `distribution_id` | [optional] AWS CloudFront distribution id | |
|
88
89
|
| `remote_path` | Directory files should be synced to. | / |
|
89
90
|
| `verbose` | [optional] Display all file actions during deploy. | false |
|
90
91
|
| `incremental` | [optional] Incremental deploy (only updated files) | false |
|
data/lib/octopress-deploy/s3.rb
CHANGED
@@ -7,9 +7,9 @@ module Octopress
|
|
7
7
|
|
8
8
|
def initialize(options)
|
9
9
|
begin
|
10
|
-
require 'aws-sdk'
|
10
|
+
require 'aws-sdk-v1'
|
11
11
|
rescue LoadError
|
12
|
-
abort "Deploying to S3 requires the aws-sdk gem. Install with `gem install aws-sdk`."
|
12
|
+
abort "Deploying to S3 requires the aws-sdk-v1 gem. Install with `gem install aws-sdk-v1`."
|
13
13
|
end
|
14
14
|
@options = options
|
15
15
|
@local = options[:site_dir] || '_site'
|
@@ -17,6 +17,7 @@ module Octopress
|
|
17
17
|
@access_key = options[:access_key_id] || ENV['AWS_ACCESS_KEY_ID']
|
18
18
|
@secret_key = options[:secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY']
|
19
19
|
@region = options[:region] || ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
20
|
+
@distro_id = options[:distribution_id] || ENV['AWS_DISTRIBUTION_ID']
|
20
21
|
@remote_path = (options[:remote_path] || '/').sub(/^\//,'')
|
21
22
|
@verbose = options[:verbose]
|
22
23
|
@incremental = options[:incremental]
|
@@ -67,17 +68,24 @@ module Octopress
|
|
67
68
|
def connect
|
68
69
|
AWS.config(access_key_id: @access_key, secret_access_key: @secret_key, region: @region)
|
69
70
|
@s3 = AWS.s3
|
71
|
+
@cloudfront = AWS.cloud_front.client
|
70
72
|
end
|
71
73
|
|
72
74
|
# Write site files to the selected bucket
|
73
75
|
#
|
74
76
|
def write_files
|
75
77
|
puts "Writing #{pluralize('file', site_files.size)}:" if @verbose
|
78
|
+
files_to_invalidate = []
|
76
79
|
site_files.each do |file|
|
77
80
|
s3_filename = remote_path(file)
|
78
81
|
o = @bucket.objects[s3_filename]
|
79
82
|
file_with_options = get_file_with_metadata(file, s3_filename);
|
80
|
-
|
83
|
+
|
84
|
+
begin
|
85
|
+
s3sum = o.etag.tr('"','') if o.exists?
|
86
|
+
rescue AWS::S3::Errors::NoSuchKey
|
87
|
+
s3sum = ""
|
88
|
+
end
|
81
89
|
|
82
90
|
if @incremental && (s3sum == Digest::MD5.file(file).hexdigest)
|
83
91
|
if @verbose
|
@@ -87,6 +95,7 @@ module Octopress
|
|
87
95
|
end
|
88
96
|
else
|
89
97
|
o.write(file_with_options)
|
98
|
+
files_to_invalidate.push(file)
|
90
99
|
if @verbose
|
91
100
|
puts "+ #{remote_path(file)}"
|
92
101
|
else
|
@@ -94,6 +103,23 @@ module Octopress
|
|
94
103
|
end
|
95
104
|
end
|
96
105
|
end
|
106
|
+
|
107
|
+
invalidate_cache(files_to_invalidate) unless @distro_id.nil?
|
108
|
+
end
|
109
|
+
|
110
|
+
def invalidate_cache(files)
|
111
|
+
puts "Invalidating cache for #{pluralize('file', site_files.size)}" if @verbose
|
112
|
+
@cloudfront.create_invalidation(
|
113
|
+
distribution_id: @distro_id,
|
114
|
+
invalidation_batch:{
|
115
|
+
paths:{
|
116
|
+
quantity: files.size,
|
117
|
+
items: files.map{|file| "/" + remote_path(file)}
|
118
|
+
},
|
119
|
+
# String of 8 random chars to uniquely id this invalidation
|
120
|
+
caller_reference: (0...8).map { ('a'..'z').to_a[rand(26)] }.join
|
121
|
+
}
|
122
|
+
) unless files.empty?
|
97
123
|
end
|
98
124
|
|
99
125
|
def get_file_with_metadata(file, s3_filename)
|
@@ -237,6 +263,7 @@ module Octopress
|
|
237
263
|
#{"bucket_name: #{options[:bucket_name]}".ljust(40)} # Name of the S3 bucket where these files will be stored.
|
238
264
|
#{"access_key_id: #{options[:access_key_id]}".ljust(40)} # Get this from your AWS console at aws.amazon.com.
|
239
265
|
#{"secret_access_key: #{options[:secret_access_key]}".ljust(40)} # Keep it safe; keep it secret. Keep this file in your .gitignore.
|
266
|
+
#{"distribution_id: #{options[:distribution_id]}".ljust(40)} # Get this from your CloudFront page at https://console.aws.amazon.com/cloudfront/
|
240
267
|
#{"remote_path: #{options[:remote_path] || '/'}".ljust(40)} # relative path on bucket where files should be copied.
|
241
268
|
#{"region: #{options[:remote_path] || 'us-east-1'}".ljust(40)} # Region where your bucket is located.
|
242
269
|
#{"verbose: #{options[:verbose] || 'false'}".ljust(40)} # Print out all file operations.
|
data/octopress-deploy.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "octopress"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "clash"
|
26
|
-
spec.add_development_dependency "aws-sdk"
|
26
|
+
spec.add_development_dependency "aws-sdk-v1"
|
27
27
|
|
28
28
|
if RUBY_VERSION >= "2"
|
29
29
|
spec.add_development_dependency "pry-byebug"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorator
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: aws-sdk
|
84
|
+
name: aws-sdk-v1
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|