tagging 0.0.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +15 -30
- data/bin/git-tagging +54 -21
- data/lib/tagging/app_version.rb +37 -16
- data/lib/tagging/version.rb +1 -1
- data/lib/tagging.rb +0 -1
- data/tagging.gemspec +2 -2
- metadata +3 -6
- data/lib/gem_version.rb +0 -67
- data/lib/tagging/gem_version.rb +0 -62
- data/lib/tagging/tasks/gem_version.rake +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ece77b05d75ff8933edb236c0ded896bbfbb4f6
|
4
|
+
data.tar.gz: 599c773e9a58e466593b0bc4d64634920e641573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca854995e01c57a4507c0ecb4a1f22d808b91fa4d7e91d27e3ad737c44843daede0253a633bb8e839ccd56e23b87caf4c975309e37d1c93712306d6c6739aa51
|
7
|
+
data.tar.gz: baaa21d142bb6e9a2ae404c1f9f262379ec6eb7f6bac2addcca3ba3b9505d137547f6d1532c01129864c643947bc55da22472bcae236b6e9bcd00b5119d0faeb
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Tagging
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/tagging.svg)](https://badge.fury.io/rb/tagging)
|
4
|
+
|
3
5
|
Automated version management for your Gem builds.
|
4
6
|
|
5
7
|
## Resources
|
@@ -24,47 +26,30 @@ Never bother updating the version for your next gem build by hand. Configured i
|
|
24
26
|
|
25
27
|
`bundle exec rake tagging:push`
|
26
28
|
|
27
|
-
|
29
|
+
### Bash
|
28
30
|
|
29
31
|
`cd /rails/app/path && git-tagging push`
|
30
32
|
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
To add other files to the GemVersion.commit_and_push method use the block. For instance,
|
35
|
-
if you want to commit and push the gemspec file also:
|
36
|
-
|
37
|
-
task :gemspec do
|
38
|
-
File.open("#{spec.name}.gemspec", 'w') do |f|
|
39
|
-
f.write spec.to_ruby
|
40
|
-
end
|
41
|
-
GemVersion.increment_version
|
42
|
-
GemVersion.commit_and_push do |git|
|
43
|
-
git.add("#{spec.name}.gemspec")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
## Bumping or resetting the next gem version
|
48
|
-
|
49
|
-
GemVersion creates a file named 'next_gem_version' in the root directory of your project which contains the 'next' gem version. Edit the version in this file or use the rake tasks to bump or set the version for the next build.
|
34
|
+
* It's necessary that your server have ssh permission. Seting a git user
|
50
35
|
|
51
|
-
|
36
|
+
`git-tagging push --config user.email para.alves@gmail.com user.name "Altherlex Alves"`
|
52
37
|
|
53
|
-
## Rake tasks
|
54
38
|
|
55
|
-
|
39
|
+
* Load remote tags
|
56
40
|
|
57
|
-
|
41
|
+
`git-tagging --version -f`
|
58
42
|
|
59
|
-
rake gem:clean
|
60
43
|
|
61
|
-
|
44
|
+
### AWS OpsWorkers + CircleCI
|
62
45
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
46
|
+
```
|
47
|
+
production:
|
48
|
+
branch: master
|
49
|
+
commands:
|
50
|
+
- git-tagging --push
|
51
|
+
- dpl --provider=opsworks --access-key-id=$AWS_ACCESS_KEY_ID --secret-access-key="$AWS_SECRET_ACCESS_KEY" --app-id=$AWS_APP_ID --wait-until-deployed --custom_json='{"deploy":{"my_app":{"scm":{"revision":"tags/$(git-tagging --version)" }}}}' --skip_cleanup
|
52
|
+
```
|
68
53
|
|
69
54
|
|
70
55
|
## Dependencies
|
data/bin/git-tagging
CHANGED
@@ -3,20 +3,24 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'tagging/app_version'
|
6
|
-
require 'tagging/gem_version'
|
7
6
|
|
8
7
|
module Tagging
|
9
8
|
class CLI
|
10
9
|
|
11
10
|
def self.run(options)
|
11
|
+
app_version = Tagging::AppVersion.new(options)
|
12
|
+
|
12
13
|
if options[:push]
|
13
|
-
puts
|
14
|
+
puts app_version.increment_and_push
|
14
15
|
exit 0
|
15
16
|
elsif options[:version]
|
16
|
-
puts
|
17
|
+
puts app_version.version
|
17
18
|
exit 0
|
18
19
|
elsif options[:next_version]
|
19
|
-
puts
|
20
|
+
puts app_version.increment_version
|
21
|
+
exit 0
|
22
|
+
elsif options[:load_tags]
|
23
|
+
puts app_version.load_tags
|
20
24
|
exit 0
|
21
25
|
else
|
22
26
|
puts "## [message] Run `tagging --help' for more options."
|
@@ -33,26 +37,55 @@ module Tagging
|
|
33
37
|
end
|
34
38
|
|
35
39
|
options = {}
|
36
|
-
opt_parser = OptionParser.new do |opt|
|
37
|
-
opt.banner = "Usage: tagging [OPTIONS]"
|
38
|
-
opt.separator ""
|
39
|
-
opt.separator "Options"
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
opt.on("-v","--version","Show current version into rails app path") do |value|
|
46
|
-
options[:version] = value
|
47
|
-
end
|
41
|
+
if ARGV.first == 'push'
|
42
|
+
options[:push] = true
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
opt_parser = OptionParser.new do |opt|
|
45
|
+
opt.banner = "Usage: git-tagging push [OPTIONS]"
|
46
|
+
opt.separator ""
|
47
|
+
opt.separator "Options"
|
48
|
+
|
49
|
+
# git config --global
|
50
|
+
opt.on("--config [variables]", "user.email \"you@example.com\" and user.name \"Name\". Like `git config --global`", String) do |value|
|
51
|
+
options[:config] = Hash[*ARGV]
|
52
|
+
end
|
53
|
+
|
54
|
+
opt.on("-m", "Tag message", String) do |message|
|
55
|
+
options[:message] = message
|
56
|
+
end
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
opt.on_tail("-h","--help","help push command") do
|
59
|
+
puts opt_parser
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
else
|
64
|
+
opt_parser = OptionParser.new do |opt|
|
65
|
+
opt.banner = "Usage: git-tagging [OPTIONS]"
|
66
|
+
opt.separator ""
|
67
|
+
opt.separator "Options"
|
68
|
+
|
69
|
+
# opt.on("-p","--push","Increment version and push to tag") do |value|
|
70
|
+
# options[:push] = value
|
71
|
+
# end
|
72
|
+
|
73
|
+
opt.on("-v","--version","Show current version into rails app path") do |value|
|
74
|
+
options[:version] = value
|
75
|
+
end
|
76
|
+
|
77
|
+
opt.on("-n","--next-version","Show the next version") do |value|
|
78
|
+
options[:next_version] = value
|
79
|
+
end
|
80
|
+
|
81
|
+
opt.on("-f","--fetch-tags","Load remote tags") do
|
82
|
+
options[:load_tags] = true
|
83
|
+
end
|
84
|
+
|
85
|
+
opt.on_tail("-h","--help","help") do
|
86
|
+
puts opt_parser
|
87
|
+
exit
|
88
|
+
end
|
56
89
|
end
|
57
90
|
end
|
58
91
|
opt_parser.parse!
|
data/lib/tagging/app_version.rb
CHANGED
@@ -3,16 +3,25 @@ require 'logger'
|
|
3
3
|
|
4
4
|
module Tagging
|
5
5
|
class AppVersion
|
6
|
-
@@default_commit_message = 'versioning by CI'
|
7
|
-
@@version
|
8
6
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
@@version
|
7
|
+
def initialize(options={})
|
8
|
+
@options = {message:'versioning by CI'}.merge(options)
|
9
|
+
@git = nil
|
13
10
|
end
|
14
11
|
|
15
|
-
def
|
12
|
+
def version
|
13
|
+
load_tags if @options[:load_tags]
|
14
|
+
@options[:current_version] ||= `git -C #{Dir.pwd} describe --tags $(git -C #{Dir.pwd} for-each-ref refs/tags --sort=-taggerdate --format='%(objectname)' --count=1)`.chomp
|
15
|
+
@options[:current_version] = self.class.init_version_file unless self.class.version_format_valid?(@options[:current_version])
|
16
|
+
@options[:current_version]
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_tags
|
20
|
+
puts "git -C #{Dir.pwd} fetch --tags"
|
21
|
+
`git -C #{Dir.pwd} fetch --tags`
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.version_format_valid?(v='')
|
16
25
|
(v && v =~ /^v\d+\.\d+\.\d+-[\.\d+]+$/)
|
17
26
|
end
|
18
27
|
|
@@ -20,19 +29,31 @@ module Tagging
|
|
20
29
|
initial_version = 'v0.0.1-00'
|
21
30
|
end
|
22
31
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
32
|
+
def increment_and_push
|
33
|
+
load_tags
|
34
|
+
increment_version
|
35
|
+
commit_and_push
|
26
36
|
end
|
27
37
|
|
28
|
-
def
|
29
|
-
|
38
|
+
def increment_version
|
39
|
+
@options[:current_version] = self.version.next
|
30
40
|
end
|
31
41
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
42
|
+
def set_global_config
|
43
|
+
if @options[:config]
|
44
|
+
@options[:config].each do |key, value|
|
45
|
+
@git.config(key, value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def commit_and_push(project_directory=Dir.pwd)
|
51
|
+
@git = Git.open(project_directory, :log=>Logger.new(STDOUT))
|
52
|
+
|
53
|
+
set_global_config
|
54
|
+
|
55
|
+
@git.add_tag(self.version, nil, message: @options[:message])
|
56
|
+
@git.push('origin', "refs/tags/#{self.version}")
|
36
57
|
end
|
37
58
|
end
|
38
59
|
end
|
data/lib/tagging/version.rb
CHANGED
data/lib/tagging.rb
CHANGED
data/tagging.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Alther Alves"]
|
9
9
|
s.email = ["para.alves@gmail.com"]
|
10
|
-
s.date = "2016-04-
|
11
|
-
s.homepage =
|
10
|
+
s.date = "2016-04-27"
|
11
|
+
s.homepage = 'https://github.com/altherlex/tagging'
|
12
12
|
s.summary = %q{Never bother updating the version for your next gem build by hand. Configured in your Rakefile, gem_version provides the next Gem version and stores it to the repository.}
|
13
13
|
s.description = %q{Automated version management for your Gem and RailsApp builds}
|
14
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alther Alves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -80,18 +80,15 @@ files:
|
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
82
|
- bin/git-tagging
|
83
|
-
- lib/gem_version.rb
|
84
83
|
- lib/tagging.rb
|
85
84
|
- lib/tagging/app_version.rb
|
86
|
-
- lib/tagging/gem_version.rb
|
87
85
|
- lib/tagging/tasks/app_version.rake
|
88
|
-
- lib/tagging/tasks/gem_version.rake
|
89
86
|
- lib/tagging/version.rb
|
90
87
|
- spec/gem_version_spec.rb
|
91
88
|
- spec/next_gem_version
|
92
89
|
- spec/spec.opts
|
93
90
|
- tagging.gemspec
|
94
|
-
homepage:
|
91
|
+
homepage: https://github.com/altherlex/tagging
|
95
92
|
licenses:
|
96
93
|
- MIT
|
97
94
|
metadata: {}
|
data/lib/gem_version.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'git'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
load File.dirname(__FILE__) + '/tasks/gem_version.rake'
|
6
|
-
|
7
|
-
|
8
|
-
module GemVersion
|
9
|
-
@@gem_version_file = 'next_gem_version'
|
10
|
-
@@default_commit_message = 'incremented gem version'
|
11
|
-
|
12
|
-
def self.gem_version_file=(str)
|
13
|
-
@@gem_version_file = str
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.next_version
|
17
|
-
init_version_file unless File.exist?(@@gem_version_file)
|
18
|
-
file = File.new(@@gem_version_file, 'r')
|
19
|
-
version = file.gets.chomp
|
20
|
-
raise "#{@@gem_version_file} file corrupt" unless self.version_format_valid?(version)
|
21
|
-
file.close
|
22
|
-
version
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.set_version(version)
|
26
|
-
raise "Invalid version format" unless self.version_format_valid?(version)
|
27
|
-
update_version(version)
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.version_format_valid?(version)
|
31
|
-
(version && version =~ /^\d+\.\d+[\.\d+]+$/)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.init_version_file
|
35
|
-
file = File.new(@@gem_version_file, 'w')
|
36
|
-
file.puts '0.0.1'
|
37
|
-
file.close
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.increment_and_push
|
41
|
-
self.increment_version
|
42
|
-
self.commit_and_push
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.increment_version
|
46
|
-
version = self.next_version
|
47
|
-
components = version.split('.')
|
48
|
-
components.push((components.pop.to_i + 1).to_s)
|
49
|
-
new_version = components.join('.')
|
50
|
-
update_version(new_version)
|
51
|
-
version
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.update_version(new_version)
|
55
|
-
file = File.new(@@gem_version_file, 'w')
|
56
|
-
file.puts new_version
|
57
|
-
file.close
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.commit_and_push(project_directory = nil, msg = nil, &block)
|
61
|
-
g=Git.open(project_directory || Dir.pwd, :log=>Logger.new(STDOUT))
|
62
|
-
g.add(@@gem_version_file)
|
63
|
-
yield(g) if block_given?
|
64
|
-
g.commit(msg || @@default_commit_message)
|
65
|
-
g.push
|
66
|
-
end
|
67
|
-
end
|
data/lib/tagging/gem_version.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module Tagging
|
2
|
-
class GemVersion
|
3
|
-
@@gem_version_file = 'next_gem_version'
|
4
|
-
@@default_commit_message = 'incremented gem version'
|
5
|
-
|
6
|
-
def self.gem_version_file=(str)
|
7
|
-
@@gem_version_file = str
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.next_version
|
11
|
-
init_version_file unless File.exist?(@@gem_version_file)
|
12
|
-
file = File.new(@@gem_version_file, 'r')
|
13
|
-
version = file.gets.chomp
|
14
|
-
raise "#{@@gem_version_file} file corrupt" unless self.version_format_valid?(version)
|
15
|
-
file.close
|
16
|
-
version
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.set_version(version)
|
20
|
-
raise "Invalid version format" unless self.version_format_valid?(version)
|
21
|
-
update_version(version)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.version_format_valid?(version)
|
25
|
-
(version && version =~ /^\d+\.\d+[\.\d+]+$/)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.init_version_file
|
29
|
-
file = File.new(@@gem_version_file, 'w')
|
30
|
-
file.puts '0.0.1'
|
31
|
-
file.close
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.increment_and_push
|
35
|
-
self.increment_version
|
36
|
-
self.commit_and_push
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.increment_version
|
40
|
-
version = self.next_version
|
41
|
-
components = version.split('.')
|
42
|
-
components.push((components.pop.to_i + 1).to_s)
|
43
|
-
new_version = components.join('.')
|
44
|
-
update_version(new_version)
|
45
|
-
version
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.update_version(new_version)
|
49
|
-
file = File.new(@@gem_version_file, 'w')
|
50
|
-
file.puts new_version
|
51
|
-
file.close
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.commit_and_push(project_directory = nil, msg = nil, &block)
|
55
|
-
g=Git.open(project_directory || Dir.pwd, :log=>Logger.new(STDOUT))
|
56
|
-
g.add(@@gem_version_file)
|
57
|
-
yield(g) if block_given?
|
58
|
-
g.commit(msg || @@default_commit_message)
|
59
|
-
g.push
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
namespace :tagging do
|
2
|
-
namespace :gem do
|
3
|
-
desc "Clean *.gem* files from project root"
|
4
|
-
task :clean do
|
5
|
-
FileUtils.rm_f Dir.glob('*.gem*')
|
6
|
-
exit 0
|
7
|
-
end
|
8
|
-
|
9
|
-
desc "Return and set next gem version"
|
10
|
-
task :version do
|
11
|
-
if (ENV.include?("set"))
|
12
|
-
version = ENV['set'].gsub(/'/, '')
|
13
|
-
unless Tagging::GemVersion.version_format_valid?(version)
|
14
|
-
raise "Version '#{version}' format invalid. Must only contain digits separated by decimal points."
|
15
|
-
end
|
16
|
-
Tagging::GemVersion.set_version(version)
|
17
|
-
puts "Next version set at '#{version}'"
|
18
|
-
else
|
19
|
-
puts Tagging::GemVersion.next_version
|
20
|
-
end
|
21
|
-
exit 0
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|