cap-git-tags 0.1.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +1 -0
- data/cap-git-tags.gemspec +23 -0
- data/lib/cap-git-tags/tasks/git_tags.rake +52 -0
- data/lib/cap-git-tags/version.rb +3 -0
- data/lib/cap-git-tags.rb +26 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4bd30e9711d048c8917a15ddb4705474e92356f9
|
4
|
+
data.tar.gz: a7c5a9362ab922ebe18d27b9dd1ee16699fcf37c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eef497bf190744ea7ada29a7dc55e905aa3ae5f459ea0ce86c902ecbdacf0cfd4c03ffc8ef49144fd08954540a90cc4e7074dd68a201a488474f24cc41e46d57
|
7
|
+
data.tar.gz: 2ae1ac5b73438a1aab23db8cdd05406ad0e1861c61a55e5141c252a9cdc7e148aa899a13aca97739fd12d1e01ff71b1ab7c383eda53021e6eb721e7e4a101e8f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Pete Hawkins, Adrian Dugan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# cap-git-tags
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cap-git-tags/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cap-git-tags"
|
8
|
+
spec.version = CapGitTags::VERSION
|
9
|
+
spec.authors = ["Pete Hawkins", "Adrian Dugan"]
|
10
|
+
spec.email = ["pete@phawk.co.uk", "rant@dugg.ie"]
|
11
|
+
spec.description = %q{Auto tags staging deploys, deploys last staging tag to production with a tag}
|
12
|
+
spec.summary = %q{Auto tags staging deploys, deploys last staging tag to production with a tag}
|
13
|
+
spec.homepage = "https://github.com/phawk/cap-git-tags"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
|
3
|
+
task :create_tag do
|
4
|
+
run_locally do
|
5
|
+
current_stage = fetch(:stage)
|
6
|
+
|
7
|
+
if current_stage == :production
|
8
|
+
# Production deploys use the latest staging tag or passed in ENV['TAG']
|
9
|
+
if ENV['TAG']
|
10
|
+
latest_staging_tag = production_tag = ENV['TAG']
|
11
|
+
else
|
12
|
+
latest_staging_tag = `git describe --match "staging*" --abbrev=4 HEAD`.chomp
|
13
|
+
production_tag = latest_staging_tag.sub(/^staging/, "production")
|
14
|
+
end
|
15
|
+
|
16
|
+
info "You are about to deploy: #{latest_staging_tag} to production"
|
17
|
+
ask :yes_to_confirm_deploy, "n"
|
18
|
+
|
19
|
+
if fetch(:yes_to_confirm_deploy)[0].downcase != "y"
|
20
|
+
abort "You didn't confirm the deployment"
|
21
|
+
end
|
22
|
+
|
23
|
+
unless ENV['TAG']
|
24
|
+
info "Publishing tag: #{production_tag}"
|
25
|
+
CapGitTags::Helper.publish_tag production_tag
|
26
|
+
end
|
27
|
+
|
28
|
+
set :branch, production_tag
|
29
|
+
elsif current_stage == :staging
|
30
|
+
# Staging deploys create a new tag based on user input
|
31
|
+
time = Time.new
|
32
|
+
|
33
|
+
ask :a_description_of_what_you_are_deploying, "latest changes"
|
34
|
+
|
35
|
+
safe_tag = fetch(:a_description_of_what_you_are_deploying).downcase.gsub(/[^a-z0-9]/, "-")
|
36
|
+
staging_tag = "staging-#{time.year}-#{time.month}-#{time.day}-#{time.hour}-#{time.min}-#{safe_tag}"
|
37
|
+
|
38
|
+
info "Publishing tag: #{staging_tag}"
|
39
|
+
CapGitTags::Helper.publish_tag staging_tag
|
40
|
+
|
41
|
+
info "Deploying: #{staging_tag} to staging"
|
42
|
+
set :branch, staging_tag
|
43
|
+
else
|
44
|
+
# dev environments allow any branch to be pushed and don't create a tag
|
45
|
+
info "About to deploy your current branch, enter a different branch name to override"
|
46
|
+
ask :branch, proc { CapGitTags::Helper.current_branch }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
before :starting, :create_tag
|
52
|
+
end
|
data/lib/cap-git-tags.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Ensure deploy tasks are loaded before we run
|
2
|
+
require 'capistrano/deploy'
|
3
|
+
|
4
|
+
# Load extra tasks into the deploy namespace
|
5
|
+
load File.expand_path("../cap-git-tags/tasks/git_tags.rake", __FILE__)
|
6
|
+
|
7
|
+
module CapGitTags
|
8
|
+
class Helper
|
9
|
+
|
10
|
+
def self.git(cmd)
|
11
|
+
`git #{cmd} 2>&1`.chomp
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.publish_tag(tag_name)
|
15
|
+
git "tag -a #{tag_name} -m \"Auto created deploy tag\""
|
16
|
+
git "push origin --tags"
|
17
|
+
|
18
|
+
"#{tag_name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.current_branch
|
22
|
+
git "rev-parse --abbrev-ref HEAD"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cap-git-tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pete Hawkins
|
8
|
+
- Adrian Dugan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: Auto tags staging deploys, deploys last staging tag to production with
|
43
|
+
a tag
|
44
|
+
email:
|
45
|
+
- pete@phawk.co.uk
|
46
|
+
- rant@dugg.ie
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- cap-git-tags.gemspec
|
57
|
+
- lib/cap-git-tags.rb
|
58
|
+
- lib/cap-git-tags/tasks/git_tags.rake
|
59
|
+
- lib/cap-git-tags/version.rb
|
60
|
+
homepage: https://github.com/phawk/cap-git-tags
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Auto tags staging deploys, deploys last staging tag to production with a
|
84
|
+
tag
|
85
|
+
test_files: []
|