tagistrano 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/lib/tagistrano/tag.rb +59 -0
- data/lib/tagistrano/tagging.rb +36 -0
- data/lib/tagistrano/version.rb +3 -0
- data/lib/tagistrano.rb +2 -0
- data/spec/lib/tagistrano/tag.rb +40 -0
- data/tagistrano.gemspec +24 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c830c94c3ff589057dbb31034f4c2242834b5ba
|
4
|
+
data.tar.gz: 35cb3072ff6fcb5a5a21e9abdd494c91dbaaf6e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58decce12694004e71c294f79838f6321c5f082ff1d626dd7c15b5f59d7e243514cb6827f1cfc6963a84d05baa4f86aa590e633fba0e1392236e3256ae6dedb1
|
7
|
+
data.tar.gz: 01b9b562225105e83b7f6762933039cbfbc4b0b5c6572adefacba7f85268e68a2a269234694089e6fe16b6cb36b1ae38d6a419ea40b1b44e6a5df557163eabe9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kyle Edson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Tagistrano
|
2
|
+
|
3
|
+
Automatically generate version-based git tags on Capistrano deploys.
|
4
|
+
|
5
|
+
This gem assumes you are using a X.X.X (major.minor.patch) version tag strategy.
|
6
|
+
Once set up, you will be prompted to choose a new tag every time a cap task is run.
|
7
|
+
The options will be generated by incrementing the highest existing version tag.
|
8
|
+
|
9
|
+
For example, if your project's current tag is 1.2.3, the prompt will look like this:
|
10
|
+
```
|
11
|
+
Tag: (leave blank to skip tagging)
|
12
|
+
1. Major 2.0.0
|
13
|
+
2. Minor 1.3.0
|
14
|
+
3. Patch 1.2.4
|
15
|
+
```
|
16
|
+
|
17
|
+
Allowing you to easily bump your project version, or skip tagging if no new version
|
18
|
+
is required.
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'tagistrano'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install tagistrano
|
35
|
+
|
36
|
+
Finally, add the following line to your Capfile:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'tagistrano'
|
40
|
+
```
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
Call the following method wherever you want the tag prompt to show:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
tag_release
|
48
|
+
```
|
49
|
+
|
50
|
+
This can be called in several places:
|
51
|
+
- In your deploy.rb file, to prompt on every cap task
|
52
|
+
- If using multiple stages, in individual stage files, to prompt on every cap task for that stage
|
53
|
+
- In cap tasks, to only prompt for that specific task
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
66
|
+
|
67
|
+
## About Foraker Labs
|
68
|
+
|
69
|
+
<img src="http://assets.foraker.com/foraker_logo.png" width="400" height="62">
|
70
|
+
|
71
|
+
This project is maintained by Foraker Labs. The names and logos of Foraker Labs are fully owned and copyright Foraker Design, LLC.
|
72
|
+
|
73
|
+
Foraker Labs is a Boulder-based Ruby on Rails and iOS development shop. Please reach out if we can [help build your product](http://www.foraker.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Tagistrano
|
2
|
+
class Tag < String
|
3
|
+
def self.next_tags
|
4
|
+
last_tag = all.last
|
5
|
+
|
6
|
+
[
|
7
|
+
last_tag.next_major_tag,
|
8
|
+
last_tag.next_minor_tag,
|
9
|
+
last_tag.next_patch_tag
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
git_tags.split(/\s+/).map { |tag| new(tag) }.sort
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.git_tags
|
18
|
+
`git tag`
|
19
|
+
end
|
20
|
+
|
21
|
+
def next_major_tag
|
22
|
+
[major + 1, 0, 0].join('.')
|
23
|
+
end
|
24
|
+
|
25
|
+
def next_minor_tag
|
26
|
+
[major, minor + 1, 0].join('.')
|
27
|
+
end
|
28
|
+
|
29
|
+
def next_patch_tag
|
30
|
+
[major, minor, patch + 1].join('.')
|
31
|
+
end
|
32
|
+
|
33
|
+
def <=>(other)
|
34
|
+
version <=> other.version
|
35
|
+
end
|
36
|
+
|
37
|
+
def version
|
38
|
+
[major, minor, patch]
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def numbers
|
44
|
+
split(".")
|
45
|
+
end
|
46
|
+
|
47
|
+
def major
|
48
|
+
numbers[0].to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
def minor
|
52
|
+
numbers[1].to_i
|
53
|
+
end
|
54
|
+
|
55
|
+
def patch
|
56
|
+
numbers[2].to_i
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/core_ext"
|
3
|
+
require "colorize"
|
4
|
+
require 'tagistrano/tag'
|
5
|
+
|
6
|
+
def tag_release
|
7
|
+
if tag = ask_for_tag.presence
|
8
|
+
puts "\nTagging as #{tag}\n\n".colorize(:green)
|
9
|
+
`git tag #{tag}`
|
10
|
+
`git push --tags`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def ask_for_tag
|
15
|
+
next_tags = Tagistrano::Tag.next_tags
|
16
|
+
|
17
|
+
puts "\nTag: (leave blank to skip tagging)".underline
|
18
|
+
|
19
|
+
prompt = <<-prompt
|
20
|
+
|
21
|
+
1. Major #{next_tags.first}
|
22
|
+
2. Minor #{next_tags.second}
|
23
|
+
3. Patch #{next_tags.third}
|
24
|
+
prompt
|
25
|
+
|
26
|
+
ask(prompt, '')
|
27
|
+
|
28
|
+
option = fetch(prompt)
|
29
|
+
|
30
|
+
if ["1", "2", "3", ""].include?(option.strip)
|
31
|
+
option.to_i > 0 ? next_tags[option.to_i - 1] : nil
|
32
|
+
else
|
33
|
+
puts "Didn't get 1, 2, 3 or blank".colorize(:red)
|
34
|
+
ask_for_tag
|
35
|
+
end
|
36
|
+
end
|
data/lib/tagistrano.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'tagistrano/tag'
|
2
|
+
|
3
|
+
module Tagistrano
|
4
|
+
describe Tag do
|
5
|
+
describe '.next_tags' do
|
6
|
+
it 'returns an array of the next tag options' do
|
7
|
+
allow(described_class).to receive(:git_tags).and_return %q(
|
8
|
+
0.0.1
|
9
|
+
0.1.0
|
10
|
+
1.0.0
|
11
|
+
1.0.1
|
12
|
+
)
|
13
|
+
|
14
|
+
expect(described_class.next_tags).to eq(['2.0.0', '1.1.0', '1.0.2'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'version incrementing' do
|
19
|
+
let(:tag) { described_class.new('1.2.3') }
|
20
|
+
|
21
|
+
describe '#next_major_tag' do
|
22
|
+
it 'increments the major version' do
|
23
|
+
expect(tag.next_major_tag).to eq '2.0.0'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#next_minor_tag' do
|
28
|
+
it 'increments the minor version' do
|
29
|
+
expect(tag.next_minor_tag).to eq '1.3.0'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#next_patch_tag' do
|
34
|
+
it 'increments the patch version' do
|
35
|
+
expect(tag.next_patch_tag).to eq '1.2.4'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/tagistrano.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tagistrano/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'tagistrano'
|
8
|
+
spec.version = Tagistrano::VERSION
|
9
|
+
spec.authors = ['Kyle Edson']
|
10
|
+
spec.email = ['kae@foraker.com']
|
11
|
+
spec.description = 'Automatically create git tags on Capistrano tasks'
|
12
|
+
spec.summary = 'Add prompts to Capistrano tasks to automatically generate new git tags based on semantic versioning'
|
13
|
+
spec.homepage = 'https://github.com/foraker/tagistrano'
|
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', '~> 0'
|
22
|
+
spec.add_development_dependency 'rake', '~> 0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tagistrano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyle Edson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Automatically create git tags on Capistrano tasks
|
56
|
+
email:
|
57
|
+
- kae@foraker.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/tagistrano.rb
|
68
|
+
- lib/tagistrano/tag.rb
|
69
|
+
- lib/tagistrano/tagging.rb
|
70
|
+
- lib/tagistrano/version.rb
|
71
|
+
- spec/lib/tagistrano/tag.rb
|
72
|
+
- tagistrano.gemspec
|
73
|
+
homepage: https://github.com/foraker/tagistrano
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Add prompts to Capistrano tasks to automatically generate new git tags based
|
97
|
+
on semantic versioning
|
98
|
+
test_files:
|
99
|
+
- spec/lib/tagistrano/tag.rb
|