auto_tagger 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG +30 -0
- data/VERSION +1 -0
- data/auto_tagger.gemspec +80 -0
- data/features/autotag.feature +39 -0
- data/features/deployment.feature +29 -0
- data/features/step_definitions/autotag_steps.rb +41 -0
- data/features/step_definitions/deployment_steps.rb +53 -0
- data/features/support/env.rb +8 -0
- data/features/support/step_helpers.rb +136 -0
- data/features/templates/cap_ext_deploy.erb +32 -0
- data/features/templates/deploy.erb +34 -0
- data/features/templates/stage.erb +1 -0
- data/geminstaller.yml +7 -0
- data/lib/auto_tagger/stage_manager.rb +2 -2
- data/recipes/release_tagger.rb +2 -3
- data/spec/auto_tagger/capistrano_helper_spec.rb +2 -2
- data/spec/auto_tagger/stage_manager_spec.rb +6 -2
- metadata +36 -15
data/.gitignore
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
2009-10-15
|
2
|
+
|
3
|
+
- You can now define your stages as strings or symbols and auto-tagger will not fail (thanks to Chad Wooley for the bug report)
|
4
|
+
- When deploying from a branch auto_tagger uses real_revision, not the previous tag, to create the new tag (Brian Takita)
|
5
|
+
|
6
|
+
2009-04-30
|
7
|
+
|
8
|
+
- Fixed bug whereby auto-tagger would use the wrong tag because it found tags that had similar names to what it uses.
|
9
|
+
|
10
|
+
2009-04-20
|
11
|
+
|
12
|
+
- `release_tagger:create_tag` creates a production tag if you don't set any stages
|
13
|
+
|
14
|
+
2009-04-05
|
15
|
+
|
16
|
+
- Added basic support for cap-ext-multistage
|
17
|
+
- Changed "stages" variable to "autotagger_stages" so as not to conflict with the multistage "stages" variable in capistrano
|
18
|
+
- Changed the :current_stage variable in the capistrano tasks to just :stage
|
19
|
+
|
20
|
+
2009-03-31
|
21
|
+
|
22
|
+
- Capistrano bases new tags off of old tags from the previous environment when tagging if there is a tag from the previous environment
|
23
|
+
- Added the following cap tasks:
|
24
|
+
- print_latest_tags
|
25
|
+
- read_tag_from_shared
|
26
|
+
- write_tag_to_shared
|
27
|
+
|
28
|
+
2009-03-29
|
29
|
+
|
30
|
+
- Capistrano tasks :set_branch no longer sets the branch to nil. If the CapistranoHelper returns nil, it leaves the branch alone.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/auto_tagger.gemspec
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{auto_tagger}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeff Dean", "Brian Takita"]
|
12
|
+
s.date = %q{2009-10-15}
|
13
|
+
s.default_executable = %q{autotag}
|
14
|
+
s.email = %q{jeff@zilkey.com}
|
15
|
+
s.executables = ["autotag"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"CHANGELOG",
|
22
|
+
"MIT-LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"VERSION",
|
25
|
+
"auto_tagger.gemspec",
|
26
|
+
"bin/autotag",
|
27
|
+
"features/autotag.feature",
|
28
|
+
"features/deployment.feature",
|
29
|
+
"features/step_definitions/autotag_steps.rb",
|
30
|
+
"features/step_definitions/deployment_steps.rb",
|
31
|
+
"features/support/env.rb",
|
32
|
+
"features/support/step_helpers.rb",
|
33
|
+
"features/templates/cap_ext_deploy.erb",
|
34
|
+
"features/templates/deploy.erb",
|
35
|
+
"features/templates/stage.erb",
|
36
|
+
"geminstaller.yml",
|
37
|
+
"lib/auto_tagger.rb",
|
38
|
+
"lib/auto_tagger/auto_tagger.rb",
|
39
|
+
"lib/auto_tagger/capistrano_helper.rb",
|
40
|
+
"lib/auto_tagger/commander.rb",
|
41
|
+
"lib/auto_tagger/repository.rb",
|
42
|
+
"lib/auto_tagger/stage_manager.rb",
|
43
|
+
"lib/auto_tagger/tag.rb",
|
44
|
+
"recipes/release_tagger.rb",
|
45
|
+
"spec/auto_tagger/auto_tagger_spec.rb",
|
46
|
+
"spec/auto_tagger/capistrano_helper_spec.rb",
|
47
|
+
"spec/auto_tagger/commander_spec.rb",
|
48
|
+
"spec/auto_tagger/repository_spec.rb",
|
49
|
+
"spec/auto_tagger/stage_manager_spec.rb",
|
50
|
+
"spec/auto_tagger/tag_spec.rb",
|
51
|
+
"spec/spec_helper.rb"
|
52
|
+
]
|
53
|
+
s.homepage = %q{http://github.com/zilkey/auto_tagger}
|
54
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
55
|
+
s.require_paths = ["lib", "recipes"]
|
56
|
+
s.rubygems_version = %q{1.3.5}
|
57
|
+
s.summary = %q{Helps you automatically create tags for each stage in a multi-stage deploment and deploy from the latest tag from the previous environment}
|
58
|
+
s.test_files = [
|
59
|
+
"spec/auto_tagger/auto_tagger_spec.rb",
|
60
|
+
"spec/auto_tagger/capistrano_helper_spec.rb",
|
61
|
+
"spec/auto_tagger/commander_spec.rb",
|
62
|
+
"spec/auto_tagger/repository_spec.rb",
|
63
|
+
"spec/auto_tagger/stage_manager_spec.rb",
|
64
|
+
"spec/auto_tagger/tag_spec.rb",
|
65
|
+
"spec/spec_helper.rb"
|
66
|
+
]
|
67
|
+
|
68
|
+
if s.respond_to? :specification_version then
|
69
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
70
|
+
s.specification_version = 3
|
71
|
+
|
72
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
73
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 2.5.3"])
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<capistrano>, [">= 2.5.3"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<capistrano>, [">= 2.5.3"])
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: Deployment
|
2
|
+
In order to get auto-tagging goodness on ci boxes
|
3
|
+
As a ruby and git ninja
|
4
|
+
I want to be able to easily create a tag from the command line with the same name format as the one created by the cap tasks
|
5
|
+
|
6
|
+
Scenario: user runs autotag with no args
|
7
|
+
Given a repo
|
8
|
+
When I run autotag with no arguments
|
9
|
+
Then I should see "USAGE:"
|
10
|
+
And no tags should be created
|
11
|
+
|
12
|
+
Scenario: user runs autotag with "--help"
|
13
|
+
Given a repo
|
14
|
+
When I run autotag with "--help"
|
15
|
+
Then I should see "USAGE:"
|
16
|
+
And no tags should be created
|
17
|
+
|
18
|
+
Scenario: user runs autotag with "-h"
|
19
|
+
Given a repo
|
20
|
+
When I run autotag with "-h"
|
21
|
+
Then I should see "USAGE:"
|
22
|
+
And no tags should be created
|
23
|
+
|
24
|
+
Scenario: user runs autotag with "-?"
|
25
|
+
Given a repo
|
26
|
+
When I run autotag with "-?"
|
27
|
+
Then I should see "USAGE:"
|
28
|
+
And no tags should be created
|
29
|
+
|
30
|
+
Scenario: user runs autotag with "demo"
|
31
|
+
Given a repo
|
32
|
+
When I run autotag with "demo"
|
33
|
+
# can't check output here for some reason
|
34
|
+
Then a "demo" tag should be created
|
35
|
+
|
36
|
+
Scenario: user runs autotag with "demo ."
|
37
|
+
Given a repo
|
38
|
+
When I run autotag with "demo"
|
39
|
+
Then a "demo" tag should be created
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: Deployment
|
2
|
+
In order to get auto-tagging goodness
|
3
|
+
As a ruby and git ninja
|
4
|
+
I want cap to do all the work for me
|
5
|
+
|
6
|
+
Scenario: user deploys with single file deploy.rb with 3 stages
|
7
|
+
Given a three-stage app using single deploy file
|
8
|
+
And a ci tag
|
9
|
+
When I deploy to staging
|
10
|
+
Then a tag should be added to git
|
11
|
+
|
12
|
+
Scenario: user deploys with single file deploy.rb with no stages
|
13
|
+
Given a one-stage app using single deploy file with the following environments:
|
14
|
+
|production |
|
15
|
+
When I deploy
|
16
|
+
Then a "production" tag should be added to git
|
17
|
+
|
18
|
+
Scenario: user deploys with single file deploy.rb stages with dashes in the name
|
19
|
+
Given a one-stage app using single deploy file with the following environments:
|
20
|
+
|staging |
|
21
|
+
|secret-production |
|
22
|
+
When I deploy to secret-production
|
23
|
+
Then a "secret-production" tag should be added to git
|
24
|
+
|
25
|
+
Scenario: user deploys with cap-ext multistage
|
26
|
+
Given a three-stage app using cap-multistage
|
27
|
+
And a ci tag
|
28
|
+
When I deploy to staging
|
29
|
+
Then a tag should be added to git
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Given /^a repo$/ do
|
2
|
+
puts
|
3
|
+
helpers = StepHelpers.new
|
4
|
+
helpers.create_git_repo
|
5
|
+
helpers.create_app
|
6
|
+
@tags = helpers.tags
|
7
|
+
puts
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I run autotag with no arguments$/ do
|
11
|
+
puts
|
12
|
+
helpers = StepHelpers.new
|
13
|
+
@output = helpers.run_autotag
|
14
|
+
@tags = helpers.tags
|
15
|
+
puts
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I run autotag with "([^\"]*)"$/ do |args|
|
19
|
+
puts
|
20
|
+
helpers = StepHelpers.new
|
21
|
+
@output = helpers.run_autotag(args)
|
22
|
+
@tags = helpers.tags
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
|
26
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
27
|
+
@output.should =~ /#{Regexp.escape(text)}/
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^no tags should be created$/ do
|
31
|
+
@tags.strip.should == ""
|
32
|
+
end
|
33
|
+
|
34
|
+
Then /^a "([^\"]*)" tag should be added to git$/ do |stage|
|
35
|
+
helpers = StepHelpers.new
|
36
|
+
helpers.tags.starts_with?(stage).should be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
Then /^a "([^\"]*)" tag should be created$/ do |prefix|
|
40
|
+
@tags.strip.split("\n").any?{|tag| tag.starts_with?("demo")}.should be_true
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Given /^a three-stage app using single deploy file$/ do
|
2
|
+
puts
|
3
|
+
helpers = StepHelpers.new
|
4
|
+
helpers.create_app_with_single_deploy_file([:ci, :staging, :production])
|
5
|
+
puts
|
6
|
+
@tags = helpers.tags
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /^a one\-stage app using single deploy file with the following environments:$/ do |table|
|
10
|
+
puts
|
11
|
+
helpers = StepHelpers.new
|
12
|
+
helpers.create_app_with_single_deploy_file table.raw.map(&:first)
|
13
|
+
puts
|
14
|
+
@tags = helpers.tags
|
15
|
+
end
|
16
|
+
|
17
|
+
Given /^a three-stage app using cap-multistage$/ do
|
18
|
+
puts
|
19
|
+
helpers = StepHelpers.new
|
20
|
+
helpers.create_app_with_cap_ext_multistage
|
21
|
+
puts
|
22
|
+
@tags = helpers.tags
|
23
|
+
end
|
24
|
+
|
25
|
+
Given /^a ci tag$/ do
|
26
|
+
puts
|
27
|
+
helpers = StepHelpers.new
|
28
|
+
helpers.autotag("ci")
|
29
|
+
@tags = helpers.tags
|
30
|
+
puts
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^I deploy to (.*)$/ do |environment|
|
34
|
+
puts
|
35
|
+
helpers = StepHelpers.new
|
36
|
+
helpers.deploy(environment)
|
37
|
+
puts
|
38
|
+
end
|
39
|
+
|
40
|
+
When /^I deploy$/ do
|
41
|
+
puts
|
42
|
+
helpers = StepHelpers.new
|
43
|
+
helpers.deploy
|
44
|
+
puts
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^a tag should be added to git$/ do
|
48
|
+
puts
|
49
|
+
helpers = StepHelpers.new
|
50
|
+
new_tags = helpers.tags
|
51
|
+
@tags.length.should < new_tags.length
|
52
|
+
puts
|
53
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
class StepHelpers
|
2
|
+
|
3
|
+
attr_reader :test_files_dir, :app_dir, :repo_dir
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@test_files_dir = File.join(Dir.pwd, "test_files")
|
7
|
+
@app_dir = File.join(test_files_dir, "app")
|
8
|
+
@repo_dir = File.join(test_files_dir, "repo")
|
9
|
+
end
|
10
|
+
|
11
|
+
def reset
|
12
|
+
FileUtils.rm_r(test_files_dir) if File.exists?(test_files_dir)
|
13
|
+
FileUtils.mkdir_p(test_files_dir)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_git_repo
|
17
|
+
FileUtils.mkdir_p repo_dir
|
18
|
+
`cd #{repo_dir} && git --bare init`
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_app_with_single_deploy_file(environments)
|
22
|
+
create_git_repo
|
23
|
+
create_app
|
24
|
+
capify_app
|
25
|
+
create_single_deploy_file(environments)
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_autotag(args = nil)
|
29
|
+
cmd = "cd #{app_dir} && ../../bin/autotag"
|
30
|
+
cmd += " #{args}" if args
|
31
|
+
`#{cmd}`
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_app_with_cap_ext_multistage
|
35
|
+
create_git_repo
|
36
|
+
create_app
|
37
|
+
capify_app
|
38
|
+
create_cap_ext_multistage_deploy_files
|
39
|
+
end
|
40
|
+
|
41
|
+
def deploy(stage = nil)
|
42
|
+
deploy_command = "cap "
|
43
|
+
deploy_command += "#{stage} " if stage
|
44
|
+
deploy_command += "deploy"
|
45
|
+
|
46
|
+
run_commands [
|
47
|
+
"cd #{app_dir}",
|
48
|
+
"cap deploy:setup",
|
49
|
+
deploy_command
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def autotag(stage)
|
54
|
+
system "cd #{app_dir} && git tag #{stage}/#{Time.now.utc.strftime('%Y%m%d%H%M%S')} && git push origin --tags"
|
55
|
+
end
|
56
|
+
|
57
|
+
def tags
|
58
|
+
system "cd #{app_dir} && git fetch origin --tags"
|
59
|
+
tags = `cd #{app_dir} && git tag`
|
60
|
+
puts tags
|
61
|
+
tags
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_app
|
65
|
+
FileUtils.mkdir_p app_dir
|
66
|
+
run_commands [
|
67
|
+
"cd #{app_dir}",
|
68
|
+
"touch README",
|
69
|
+
"git init",
|
70
|
+
"git add .",
|
71
|
+
%Q{git commit -m "first commit"},
|
72
|
+
"git remote add origin file://#{repo_dir}",
|
73
|
+
"git push origin master"
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def capify_app
|
80
|
+
run_commands [
|
81
|
+
"cd #{app_dir}",
|
82
|
+
"mkdir config",
|
83
|
+
"capify ."
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_single_deploy_file(environments)
|
88
|
+
repository = repo_dir
|
89
|
+
deploy_to = File.join(test_files_dir, "deployed")
|
90
|
+
git_location = `which git`.strip
|
91
|
+
user = Etc.getlogin
|
92
|
+
|
93
|
+
path = File.expand_path(File.join(__FILE__, "..", "..", "templates", "deploy.erb"))
|
94
|
+
#puts "TRACE %s:%s" % [__FILE__, __LINE__]
|
95
|
+
#puts path
|
96
|
+
#puts File.exists?(path)
|
97
|
+
|
98
|
+
template = ERB.new File.read(path)
|
99
|
+
output = template.result(binding)
|
100
|
+
File.open(File.join(app_dir, "config", "deploy.rb"), 'w') {|f| f.write(output) }
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_cap_ext_multistage_deploy_files
|
104
|
+
repository = repo_dir
|
105
|
+
deploy_to = File.join(test_files_dir, "deployed")
|
106
|
+
git_location = `which git`.strip
|
107
|
+
user = Etc.getlogin
|
108
|
+
environments = [:ci, :staging, :production]
|
109
|
+
|
110
|
+
path = File.expand_path(File.join(__FILE__, "..", "..", "templates", "cap_ext_deploy.erb"))
|
111
|
+
|
112
|
+
template = ERB.new File.read(path)
|
113
|
+
output = template.result(binding)
|
114
|
+
File.open(File.join(app_dir, "config", "deploy.rb"), 'w') {|f| f.write(output) }
|
115
|
+
|
116
|
+
%w(staging production).each do |stage|
|
117
|
+
create_cap_ext_multistage_deploy_stage_file(stage)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def create_cap_ext_multistage_deploy_stage_file(stage)
|
122
|
+
deploy_subdir = File.join(app_dir, "config", "deploy")
|
123
|
+
FileUtils.mkdir_p deploy_subdir
|
124
|
+
|
125
|
+
template_path = File.expand_path(File.join(__FILE__, "..", "..", "templates", "stage.erb"))
|
126
|
+
template = ERB.new File.read(template_path)
|
127
|
+
output = template.result(binding)
|
128
|
+
|
129
|
+
File.open(File.join(deploy_subdir, "#{stage}.rb"), 'w') {|f| f.write(output) }
|
130
|
+
end
|
131
|
+
|
132
|
+
def run_commands(commands)
|
133
|
+
puts `#{commands.join(" && ")}`
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "recipes", "release_tagger"))
|
2
|
+
|
3
|
+
set :autotagger_stages, [:ci, :staging, :production]
|
4
|
+
set :stages, [:staging, :production]
|
5
|
+
set :default_stage, :staging
|
6
|
+
|
7
|
+
require 'capistrano/ext/multistage'
|
8
|
+
|
9
|
+
set :application, "deployed"
|
10
|
+
set :user, "<%= user %>"
|
11
|
+
set :repository, "file://<%= repository %>"
|
12
|
+
set :scm, :git
|
13
|
+
set :scm_command, "<%= git_location %>"
|
14
|
+
|
15
|
+
set :deploy_to, "<%= deploy_to %>"
|
16
|
+
|
17
|
+
set :run_method, :run
|
18
|
+
set :ssh_options, { :forward_agent => true }
|
19
|
+
default_run_options[:pty] = true
|
20
|
+
|
21
|
+
role :app, "localhost" # => this must be mapped
|
22
|
+
|
23
|
+
namespace :deploy do
|
24
|
+
task :restart do
|
25
|
+
puts "restarting..."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
before "deploy:update_code", "release_tagger:set_branch"
|
30
|
+
after "deploy", "release_tagger:create_tag"
|
31
|
+
after "deploy", "release_tagger:write_tag_to_shared"
|
32
|
+
after "deploy", "release_tagger:print_latest_tags"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "recipes", "release_tagger"))
|
2
|
+
|
3
|
+
set :autotagger_stages, ["<%= environments.join('", "') %>"]
|
4
|
+
|
5
|
+
set :application, "deployed"
|
6
|
+
set :user, "<%= user %>"
|
7
|
+
set :repository, "file://<%= repository %>"
|
8
|
+
set :deploy_to, "<%= deploy_to %>"
|
9
|
+
set :scm, :git
|
10
|
+
set :scm_command, "<%= git_location %>"
|
11
|
+
|
12
|
+
set :run_method, :run
|
13
|
+
set :ssh_options, { :forward_agent => true }
|
14
|
+
default_run_options[:pty] = true
|
15
|
+
|
16
|
+
role :app, "localhost" # => this must be mapped
|
17
|
+
|
18
|
+
|
19
|
+
namespace :deploy do
|
20
|
+
task :restart do
|
21
|
+
puts "restarting..."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
<% environments.each do |environment| %>
|
26
|
+
task "<%= environment %>" do
|
27
|
+
set :stage, "<%= environment %>"
|
28
|
+
end
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
before "deploy:update_code", "release_tagger:set_branch"
|
32
|
+
after "deploy", "release_tagger:create_tag"
|
33
|
+
after "deploy", "release_tagger:write_tag_to_shared"
|
34
|
+
after "deploy", "release_tagger:print_latest_tags"
|
@@ -0,0 +1 @@
|
|
1
|
+
# nothing to see here...
|
data/geminstaller.yml
ADDED
@@ -10,12 +10,12 @@ class StageManager
|
|
10
10
|
|
11
11
|
def initialize(stages)
|
12
12
|
raise NoStagesSpecifiedError unless stages && stages.is_a?(Array)
|
13
|
-
@stages = stages
|
13
|
+
@stages = stages.map{|stage| stage.to_s }
|
14
14
|
end
|
15
15
|
|
16
16
|
def previous_stage(stage)
|
17
17
|
if stage
|
18
|
-
index = stages.index(stage) - 1
|
18
|
+
index = stages.index(stage.to_s) - 1
|
19
19
|
stages[index] if index > -1
|
20
20
|
end
|
21
21
|
end
|
data/recipes/release_tagger.rb
CHANGED
@@ -43,9 +43,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
43
43
|
desc %Q{Creates a tag using the stage variable}
|
44
44
|
task :create_tag, :roles => :app do
|
45
45
|
if variables[:stage]
|
46
|
-
|
47
|
-
tag_name
|
48
|
-
logger.info "AUTO TAGGER created tag #{tag_name} from #{previous_tag.inspect}"
|
46
|
+
tag_name = AutoTagger.new(variables[:stage], variables[:working_directory]).create_tag(real_revision)
|
47
|
+
logger.info "AUTO TAGGER created tag #{tag_name} from #{real_revision}"
|
49
48
|
else
|
50
49
|
tag_name = AutoTagger.new(:production, variables[:working_directory]).create_tag
|
51
50
|
logger.info "AUTO TAGGER created tag #{tag_name}"
|
@@ -112,7 +112,7 @@ describe CapistranoHelper do
|
|
112
112
|
}
|
113
113
|
tagger = Object.new
|
114
114
|
mock(tagger).latest_tag { "foo_01" }
|
115
|
-
mock(AutoTagger).new(
|
115
|
+
mock(AutoTagger).new("foo", "/foo") { tagger }
|
116
116
|
CapistranoHelper.new(variables).branch.should == "foo_01"
|
117
117
|
end
|
118
118
|
end
|
@@ -126,7 +126,7 @@ describe CapistranoHelper do
|
|
126
126
|
}
|
127
127
|
tagger = Object.new
|
128
128
|
mock(tagger).latest_tag { nil }
|
129
|
-
mock(AutoTagger).new(
|
129
|
+
mock(AutoTagger).new("foo", "/foo") { tagger }
|
130
130
|
CapistranoHelper.new(variables).branch.should == nil
|
131
131
|
end
|
132
132
|
end
|
@@ -13,14 +13,18 @@ describe StageManager do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#previous_stage" do
|
16
|
-
it "returns the previous stage if there is more than one stage, and there is a current stage" do
|
17
|
-
StageManager.new([:foo, :bar]).previous_stage(:bar).should ==
|
16
|
+
it "returns the previous stage as a string if there is more than one stage, and there is a current stage" do
|
17
|
+
StageManager.new([:foo, :bar]).previous_stage(:bar).should == "foo"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns nil if there is no previous stage" do
|
21
21
|
StageManager.new([:bar]).previous_stage(:bar).should be_nil
|
22
22
|
end
|
23
23
|
|
24
|
+
it "deals with mixed strings and symbols" do
|
25
|
+
StageManager.new([:"foo-bar", "baz"]).previous_stage(:baz).should == "foo-bar"
|
26
|
+
end
|
27
|
+
|
24
28
|
it "returns nil if there is no current stage" do
|
25
29
|
StageManager.new([:bar]).previous_stage(nil).should be_nil
|
26
30
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_tagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dean
|
8
|
+
- Brian Takita
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-
|
13
|
+
date: 2009-10-15 00:00:00 -04:00
|
13
14
|
default_executable: autotag
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -23,23 +24,39 @@ dependencies:
|
|
23
24
|
version: 2.5.3
|
24
25
|
version:
|
25
26
|
description:
|
26
|
-
email:
|
27
|
+
email: jeff@zilkey.com
|
27
28
|
executables:
|
28
29
|
- autotag
|
29
30
|
extensions: []
|
30
31
|
|
31
|
-
extra_rdoc_files:
|
32
|
-
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.md
|
33
34
|
files:
|
35
|
+
- .gitignore
|
36
|
+
- CHANGELOG
|
37
|
+
- MIT-LICENSE
|
38
|
+
- README.md
|
39
|
+
- VERSION
|
40
|
+
- auto_tagger.gemspec
|
41
|
+
- bin/autotag
|
42
|
+
- features/autotag.feature
|
43
|
+
- features/deployment.feature
|
44
|
+
- features/step_definitions/autotag_steps.rb
|
45
|
+
- features/step_definitions/deployment_steps.rb
|
46
|
+
- features/support/env.rb
|
47
|
+
- features/support/step_helpers.rb
|
48
|
+
- features/templates/cap_ext_deploy.erb
|
49
|
+
- features/templates/deploy.erb
|
50
|
+
- features/templates/stage.erb
|
51
|
+
- geminstaller.yml
|
52
|
+
- lib/auto_tagger.rb
|
34
53
|
- lib/auto_tagger/auto_tagger.rb
|
35
54
|
- lib/auto_tagger/capistrano_helper.rb
|
36
55
|
- lib/auto_tagger/commander.rb
|
37
56
|
- lib/auto_tagger/repository.rb
|
38
57
|
- lib/auto_tagger/stage_manager.rb
|
39
58
|
- lib/auto_tagger/tag.rb
|
40
|
-
- lib/auto_tagger.rb
|
41
59
|
- recipes/release_tagger.rb
|
42
|
-
- bin/autotag
|
43
60
|
- spec/auto_tagger/auto_tagger_spec.rb
|
44
61
|
- spec/auto_tagger/capistrano_helper_spec.rb
|
45
62
|
- spec/auto_tagger/commander_spec.rb
|
@@ -47,15 +64,13 @@ files:
|
|
47
64
|
- spec/auto_tagger/stage_manager_spec.rb
|
48
65
|
- spec/auto_tagger/tag_spec.rb
|
49
66
|
- spec/spec_helper.rb
|
50
|
-
- MIT-LICENSE
|
51
|
-
- README.md
|
52
67
|
has_rdoc: true
|
53
|
-
homepage: http://github.com/zilkey/
|
68
|
+
homepage: http://github.com/zilkey/auto_tagger
|
54
69
|
licenses: []
|
55
70
|
|
56
71
|
post_install_message:
|
57
|
-
rdoc_options:
|
58
|
-
|
72
|
+
rdoc_options:
|
73
|
+
- --charset=UTF-8
|
59
74
|
require_paths:
|
60
75
|
- lib
|
61
76
|
- recipes
|
@@ -76,7 +91,13 @@ requirements: []
|
|
76
91
|
rubyforge_project:
|
77
92
|
rubygems_version: 1.3.3
|
78
93
|
signing_key:
|
79
|
-
specification_version:
|
94
|
+
specification_version: 3
|
80
95
|
summary: Helps you automatically create tags for each stage in a multi-stage deploment and deploy from the latest tag from the previous environment
|
81
|
-
test_files:
|
82
|
-
|
96
|
+
test_files:
|
97
|
+
- spec/auto_tagger/auto_tagger_spec.rb
|
98
|
+
- spec/auto_tagger/capistrano_helper_spec.rb
|
99
|
+
- spec/auto_tagger/commander_spec.rb
|
100
|
+
- spec/auto_tagger/repository_spec.rb
|
101
|
+
- spec/auto_tagger/stage_manager_spec.rb
|
102
|
+
- spec/auto_tagger/tag_spec.rb
|
103
|
+
- spec/spec_helper.rb
|