phase 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/phase/cli/deploy.rb +22 -7
- data/lib/phase/kit/deploy/build.rb +33 -15
- data/lib/phase/kit/deploy/deployment.rb +24 -7
- data/lib/phase/util/shell.rb +15 -0
- data/lib/phase/version.rb +1 -1
- data/lib/phase.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0348a387cd72008efb9ac4e146666f193ac0007b
|
4
|
+
data.tar.gz: 3b871ecfcc7d89b48dcc90ff78cd114b3e749240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7912b55eb7b03d26e9fae06c27f2dd46eb7f693dfdd5e4a89207ec03880e27abfb3221eaa35a451b26f06341be771d1a69a26ce49adba59c84466eef064970f1
|
7
|
+
data.tar.gz: df587124963dc679162d2e825a5a92ed1a4b7c1b0049dde356dba42b481d252df0adce6fa3486760d2de899c51cebe4d419c07d0a1d51ab4d4c87d6b03dd1ecf
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/lib/phase/cli/deploy.rb
CHANGED
@@ -3,10 +3,12 @@ module Phase
|
|
3
3
|
class Deploy < Command
|
4
4
|
|
5
5
|
command :deploy do |c|
|
6
|
-
c.syntax = "phase deploy
|
6
|
+
c.syntax = "phase deploy [-e environment_name] version_number"
|
7
|
+
|
8
|
+
c.option "-e", "--env environment_name", String, "Deploy to this environment."
|
7
9
|
|
8
10
|
c.description = <<-EOS.strip_heredoc
|
9
|
-
Builds and deploys code to the specified
|
11
|
+
Builds and deploys code to the specified 'environment_name'. 'environment_name' may be
|
10
12
|
any environment configured in the Phasefile.
|
11
13
|
EOS
|
12
14
|
|
@@ -15,18 +17,31 @@ module Phase
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
attr_reader :
|
20
|
+
attr_reader :version_number
|
19
21
|
|
20
22
|
def initialize(args, options)
|
21
|
-
@environment = args.first
|
22
23
|
super
|
24
|
+
|
25
|
+
@version_number = args.first
|
26
|
+
|
27
|
+
fail "must specify environment with '-e'" unless options.env
|
28
|
+
fail "must specify version number" unless version_number
|
23
29
|
end
|
24
30
|
|
25
31
|
def run
|
26
|
-
|
27
|
-
|
32
|
+
opts = {
|
33
|
+
version_tag: version_number
|
34
|
+
}
|
35
|
+
|
36
|
+
deployment = case options.env
|
37
|
+
when "sandbox"
|
38
|
+
::Phase::Deploy::SandboxDeployment.new(opts)
|
39
|
+
when "staging"
|
40
|
+
::Phase::Deploy::StagingDeployment.new(opts)
|
41
|
+
when "production"
|
42
|
+
::Phase::Deploy::ProductionDeployment.new(opts)
|
28
43
|
else
|
29
|
-
|
44
|
+
fail "unknown environment: '#{environment}'"
|
30
45
|
end
|
31
46
|
|
32
47
|
deployment.execute!
|
@@ -2,42 +2,56 @@ module Phase
|
|
2
2
|
module Deploy
|
3
3
|
|
4
4
|
class Build
|
5
|
+
include ::Phase::Util::Shell
|
6
|
+
|
5
7
|
attr_reader :version_tag, :build_dir
|
6
8
|
|
7
9
|
def initialize(version_tag, options = {})
|
8
10
|
@version_tag = version_tag
|
9
|
-
@build_dir = options.fetch(:build_dir, "
|
11
|
+
@build_dir = ::Pathname.new( options.fetch(:build_dir, "build") )
|
10
12
|
end
|
11
13
|
|
12
|
-
def execute
|
14
|
+
def execute!
|
13
15
|
build_image
|
14
|
-
tag_image
|
16
|
+
# tag_image
|
15
17
|
push
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def build_image
|
21
|
-
|
23
|
+
remove_stale_build_dir
|
22
24
|
clone_local_repo
|
23
|
-
|
25
|
+
|
26
|
+
shell("docker build -t #{repo_name}:#{version_tag} #{build_dir}") do |status|
|
27
|
+
fail "couldn't build Docker image"
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
|
-
def
|
27
|
-
::FileUtils.
|
31
|
+
def remove_stale_build_dir
|
32
|
+
::FileUtils.rm_r(build_dir)
|
28
33
|
end
|
29
34
|
|
30
35
|
def clone_local_repo
|
31
|
-
|
36
|
+
shell("git clone --depth 1 -- file://$(pwd) #{build_dir}") do |status|
|
37
|
+
fail "couldn't clone local copy of git repository"
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
|
-
def tag_image
|
35
|
-
|
36
|
-
|
41
|
+
# def tag_image
|
42
|
+
# shell("docker tag #{repo_name}:#{version_tag} #{repo_name}:latest") do |status|
|
43
|
+
# fail "couldn't tag Docker image"
|
44
|
+
# end
|
45
|
+
# end
|
37
46
|
|
38
47
|
def push
|
39
|
-
|
40
|
-
|
48
|
+
shell("docker push #{repo_name}:#{version_tag}") do |status|
|
49
|
+
fail "couldn't push #{repo_name}:#{version_tag}"
|
50
|
+
end
|
51
|
+
|
52
|
+
shell("docker push #{repo_name}:latest") do |status|
|
53
|
+
fail "couldn't push #{repo_name}:latest"
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
43
57
|
def repo_name
|
@@ -55,11 +69,15 @@ module Phase
|
|
55
69
|
private
|
56
70
|
|
57
71
|
def build_image
|
58
|
-
|
72
|
+
shell("docker build -t #{repo_name}:#{version_tag} .") do |status|
|
73
|
+
fail "couldn't build Docker image"
|
74
|
+
end
|
59
75
|
end
|
60
76
|
|
61
77
|
def push
|
62
|
-
|
78
|
+
shell("docker push #{repo_name}:#{version_tag}") do |status|
|
79
|
+
fail "couldn't push #{repo_name}:#{version_tag}"
|
80
|
+
end
|
63
81
|
end
|
64
82
|
end
|
65
83
|
|
@@ -2,25 +2,42 @@ module Phase
|
|
2
2
|
module Deploy
|
3
3
|
|
4
4
|
class Deployment
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :options, :build
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
9
|
-
|
7
|
+
def initialize(options = {})
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
@build ||= Build.new(options[:version_tag])
|
10
13
|
end
|
11
14
|
|
12
15
|
def execute!
|
13
|
-
|
16
|
+
build.execute!
|
14
17
|
deploy_image
|
15
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def deploy_image
|
23
|
+
system("")
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
|
19
28
|
class SandboxDeployment < Deployment
|
20
|
-
def
|
21
|
-
@build
|
29
|
+
def build
|
30
|
+
@build ||= SandboxBuild.new(options[:version_tag])
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
34
|
+
|
35
|
+
class StagingDeployment < Deployment
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
class ProductionDeployment < Deployment
|
40
|
+
end
|
41
|
+
|
25
42
|
end
|
26
43
|
end
|
data/lib/phase/version.rb
CHANGED
data/lib/phase.rb
CHANGED
@@ -4,6 +4,7 @@ require 'colorize'
|
|
4
4
|
require 'erb'
|
5
5
|
require 'fog'
|
6
6
|
require 'progressbar'
|
7
|
+
require 'pry'
|
7
8
|
require 'sshkit'
|
8
9
|
require 'terminal-table'
|
9
10
|
|
@@ -13,6 +14,10 @@ require 'phase/adapters/abstract'
|
|
13
14
|
require 'phase/adapters/aws'
|
14
15
|
|
15
16
|
require "phase/util/console"
|
17
|
+
require "phase/util/shell"
|
18
|
+
|
19
|
+
require 'phase/kit/deploy/build'
|
20
|
+
require 'phase/kit/deploy/deployment'
|
16
21
|
|
17
22
|
require 'phase/kit/ipa/app'
|
18
23
|
require 'phase/kit/ipa/enterprise_deployment'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piers Mainwaring
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- lib/phase/tasks/deploy.rb
|
233
233
|
- lib/phase/templates/ipa_xml.plist
|
234
234
|
- lib/phase/util/console.rb
|
235
|
+
- lib/phase/util/shell.rb
|
235
236
|
- lib/phase/version.rb
|
236
237
|
- phase.gemspec
|
237
238
|
- spec/dsl_spec.rb
|