s3_deployer 0.6.3 → 0.7.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 +4 -4
- data/lib/s3_deployer.rb +15 -14
- data/lib/s3_deployer/config.rb +4 -1
- data/lib/s3_deployer/version.rb +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: 43287530ea09e3506c51488fe99d99ed4292c921
|
4
|
+
data.tar.gz: 4f81042d4d272e90de8f7ae326eaad06dc2b07e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bba3665ac748d0da69efe60ad1d5f4b30632a7c85ca0421570ad43c55bd38e65487775c1393de6c928789153c1e079944bebf7fc9eea3cad24b9a04d641a8e2
|
7
|
+
data.tar.gz: eae25b2818d5575ef1ff10ea8c10c09fbfe5c9c223953876a32322cb2aa118ca7915e8ef9e9cec86293133108c64522d102b002ab2d05ca1a3f2bdd1d52904ef
|
data/lib/s3_deployer.rb
CHANGED
@@ -37,14 +37,14 @@ class S3Deployer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def deploy!
|
40
|
-
revision = time_zone.now.strftime(DATE_FORMAT)
|
40
|
+
revision = config.revision || time_zone.now.strftime(DATE_FORMAT)
|
41
41
|
config.before_deploy[revision] if config.before_deploy
|
42
42
|
stage!(revision)
|
43
43
|
switch!(revision)
|
44
44
|
config.after_deploy[revision] if config.after_deploy
|
45
45
|
end
|
46
46
|
|
47
|
-
def stage!(revision = time_zone.now.strftime(DATE_FORMAT))
|
47
|
+
def stage!(revision = (config.revision || time_zone.now.strftime(DATE_FORMAT)))
|
48
48
|
puts "Staging #{colorize(:green, revision)}"
|
49
49
|
config.before_stage[revision] if config.before_stage
|
50
50
|
copy_files_to_s3(revision)
|
@@ -62,9 +62,8 @@ class S3Deployer
|
|
62
62
|
warn "You must specify the revision by REVISION env variable"
|
63
63
|
exit(1)
|
64
64
|
end
|
65
|
-
revision = normalize_revision(revision)
|
66
65
|
config.before_switch[current_revision, revision] if config.before_switch
|
67
|
-
prefix = config.app_path.empty? ? revision : File.join(
|
66
|
+
prefix = config.app_path.empty? ? revision : File.join(revisions_path, revision)
|
68
67
|
list_of_objects = []
|
69
68
|
Aws::S3::Resource.new.bucket(config.bucket).objects(prefix: prefix).each do |object_summary|
|
70
69
|
list_of_objects << object_summary
|
@@ -124,13 +123,13 @@ class S3Deployer
|
|
124
123
|
end
|
125
124
|
|
126
125
|
def sha_of_revision(revision)
|
127
|
-
shas_by_revisions[
|
126
|
+
shas_by_revisions[revision]
|
128
127
|
end
|
129
128
|
|
130
129
|
private
|
131
130
|
|
132
131
|
def copy_files_to_s3(rev)
|
133
|
-
dir = File.join(
|
132
|
+
dir = File.join(revisions_path, rev)
|
134
133
|
Parallel.each(source_files_list, in_threads: 20) do |file|
|
135
134
|
s3_file = Pathname.new(file).relative_path_from(Pathname.new(config.dist_dir)).to_s
|
136
135
|
store_value(File.join(dir, s3_file), File.read(file))
|
@@ -138,11 +137,9 @@ class S3Deployer
|
|
138
137
|
end
|
139
138
|
|
140
139
|
def get_list_of_revisions
|
141
|
-
prefix =
|
140
|
+
prefix = revisions_path
|
142
141
|
body = Aws::S3::Client.new.list_objects({bucket: config.bucket, delimiter: '/', prefix: prefix + "/"})
|
143
|
-
body.common_prefixes.map(&:prefix).map { |e| e.gsub(prefix, "").gsub("/", "") }.
|
144
|
-
!!(Time.strptime(dir, DATE_FORMAT) rescue nil)
|
145
|
-
end.sort
|
142
|
+
body.common_prefixes.map(&:prefix).map { |e| e.gsub(prefix, "").gsub("/", "") }.sort
|
146
143
|
end
|
147
144
|
|
148
145
|
def app_path_with_bucket
|
@@ -168,6 +165,10 @@ class S3Deployer
|
|
168
165
|
File.join(config.app_path, CURRENT_REVISION)
|
169
166
|
end
|
170
167
|
|
168
|
+
def revisions_path
|
169
|
+
File.join(config.app_path, "revisions")
|
170
|
+
end
|
171
|
+
|
171
172
|
def get_value(key)
|
172
173
|
puts "Retrieving value #{key} on S3"
|
173
174
|
retry_block(RETRY_TIMES.dup) do
|
@@ -176,14 +177,14 @@ class S3Deployer
|
|
176
177
|
end
|
177
178
|
|
178
179
|
def store_current_revision(revision)
|
179
|
-
store_value(current_revision_path, revision)
|
180
|
+
store_value(current_revision_path, revision, cache_control: "max-age=0, no-cache")
|
180
181
|
end
|
181
182
|
|
182
183
|
def store_git_hash(time)
|
183
184
|
value = shas_by_revisions.
|
184
185
|
merge(time => `git rev-parse HEAD`.strip).
|
185
186
|
map { |sha, rev| "#{sha} - #{rev}" }.join("\n")
|
186
|
-
store_value(File.join(config.app_path, "SHAS"), value)
|
187
|
+
store_value(File.join(config.app_path, "SHAS"), value, cache_control: "max-age=0, no-cache")
|
187
188
|
@shas_by_revisions = nil
|
188
189
|
end
|
189
190
|
|
@@ -193,8 +194,8 @@ class S3Deployer
|
|
193
194
|
nil
|
194
195
|
end
|
195
196
|
|
196
|
-
def store_value(key, value)
|
197
|
-
options = {acl: "public-read"}
|
197
|
+
def store_value(key, value, options = {})
|
198
|
+
options = {acl: "public-read"}.merge(options)
|
198
199
|
if config.cache_control && !config.cache_control.empty?
|
199
200
|
options[:cache_control] = config.cache_control
|
200
201
|
end
|
data/lib/s3_deployer/config.rb
CHANGED
@@ -4,7 +4,10 @@ class S3Deployer
|
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@version = ENV["VERSION"] || ""
|
7
|
-
@revision = ENV["REVISION"]
|
7
|
+
@revision = ENV["REVISION"]
|
8
|
+
@access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
9
|
+
@secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
10
|
+
|
8
11
|
@env = ENV["ENV"] || "production"
|
9
12
|
@env_settings = {}
|
10
13
|
colorize true
|
data/lib/s3_deployer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Astashov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.4.5.1
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Simple gem for deploying client apps to S3
|