step-up 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/.stepuprc CHANGED
@@ -30,7 +30,6 @@ versioning:
30
30
  - deploy_steps
31
31
  patch:
32
32
  - bugfixes
33
- tiny:
34
33
  - changes
35
34
  version_levels:
36
35
  - major
data/GEM_VERSION CHANGED
@@ -1 +1 @@
1
- v0.7.0
1
+ v0.8.0
@@ -0,0 +1,14 @@
1
+ # Capistrano task for step-up.
2
+ #
3
+ # Just add "require 'step-up/capistrano'" in your Capistrano Capfile:
4
+ # - A file CURRENT_VERSION will be created after deploy in app root
5
+ # - A task stepup:deploy_steps will be available.
6
+ require 'step-up/deployment'
7
+
8
+ Capistrano::Configuration.instance(:must_exist).load do
9
+
10
+ before "deploy:update_code", "stepup:deploy_steps"
11
+ after "deploy:update_code", "stepup:version_file"
12
+
13
+ Stepup::Deployment.define_task(self, :task, :except => { :no_release => true })
14
+ end
@@ -29,7 +29,6 @@ versioning:
29
29
  - deploy_steps
30
30
  patch:
31
31
  - bugfixes
32
- tiny:
33
32
  - changes
34
33
  version_levels:
35
34
  - major
@@ -0,0 +1,100 @@
1
+ module Stepup
2
+ class Deployment
3
+ def self.define_task(context, task_method = :task, opts = {})
4
+ if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
5
+ context_name = "capistrano"
6
+ role_default = "{:except => {:no_release => true}}"
7
+ else
8
+ context_name = "vlad"
9
+ role_default = "[:app]"
10
+ end
11
+
12
+ context.send :namespace, :stepup do
13
+ send :desc, <<-DESC
14
+ Generates file CURRENT_VERSION with the current version of the application
15
+ DESC
16
+ send task_method, :version_file, opts do
17
+ info "Generating CURRENT_VERSION file..."
18
+ run "cd #{context.fetch(:release_path)}; stepup > CURRENT_VERSION"
19
+ end
20
+
21
+ send :desc, <<-DESC
22
+ Show all steps required for deployment
23
+ DESC
24
+ send task_method, :deploy_steps, opts do
25
+ # Get the current version from remote
26
+ run("cat #{context.fetch(:current_release)}/CURRENT_VERSION") do |channel, stream, data|
27
+ set :current_version_from_remote, data.chomp
28
+ end
29
+
30
+ version_to_deploy = get_version_to_deploy(context)
31
+ current_version_from_remote = context[:current_version_from_remote]
32
+
33
+ if version_to_deploy
34
+ if current_version_from_remote
35
+ info "You are about to deploy #{version_to_deploy} version in replace to current #{current_version_from_remote}"
36
+
37
+ info "Please wait while I'm looking for required steps to deploy..."
38
+
39
+ deploy_sections = get_deploy_sections(context)
40
+ notes = run_locally("stepup notes --after=#{current_version_from_remote} --upto=#{version_to_deploy} --sections=#{deploy_sections}")
41
+
42
+ print_text notes
43
+
44
+ important "Please be sure to review all the steps above before proceeding with the deployment!"
45
+ else
46
+ error("Can not find version from remote, so it's impossible to show deploy steps")
47
+ end
48
+ else
49
+ error("Can not find version for deployment. Please, set TAG variable. Example:\n\t TAG=v1.0.0 cap <env> stepup:deploy_steps")
50
+ end
51
+ end
52
+
53
+ def get_version_to_deploy(context)
54
+ context.fetch(:branch, false) || ENV['TAG']
55
+ end
56
+
57
+ def get_deploy_sections(context)
58
+ deploy_sections = context.fetch(:deploy_sections, false) || ['deploy_steps']
59
+ deploy_sections.join(' ')
60
+ end
61
+
62
+ def print_text(text)
63
+ if colorize?
64
+ puts text
65
+ else
66
+ logger.info(text)
67
+ end
68
+ end
69
+
70
+ def info(message)
71
+ if colorize?
72
+ puts "\033[0;32m=> [step-up] #{message}\033[0m"
73
+ else
74
+ logger.info("[step-up] #{message}")
75
+ end
76
+ end
77
+
78
+ def important(message)
79
+ if colorize?
80
+ puts "\033[0;33m=> [step-up] #{message}\033[0m"
81
+ else
82
+ logger.important("[step-up] #{message}")
83
+ end
84
+ end
85
+
86
+ def error(message)
87
+ if colorize?
88
+ puts "\033[0;31m=> [step-up] #{message}\033[0m"
89
+ else
90
+ logger.error("[step-up] #{message}")
91
+ end
92
+ end
93
+
94
+ def colorize?
95
+ $stdout.tty?
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: step-up
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcelo Manzan
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-19 00:00:00 Z
19
+ date: 2011-11-21 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: thor
@@ -78,9 +78,11 @@ files:
78
78
  - Rakefile
79
79
  - bin/stepup
80
80
  - lib/step-up.rb
81
+ - lib/step-up/capistrano.rb
81
82
  - lib/step-up/cli.rb
82
83
  - lib/step-up/config.rb
83
84
  - lib/step-up/config/step-up.yml
85
+ - lib/step-up/deployment.rb
84
86
  - lib/step-up/driver.rb
85
87
  - lib/step-up/driver/git.rb
86
88
  - lib/step-up/git_extensions.rb