release_me 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +47 -0
- data/.rubocop.yml +73 -0
- data/README.md +28 -0
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/exe/bump_and_tag +1 -2
- data/exe/bump_version +1 -2
- data/lib/release_me/adapter.rb +13 -16
- data/lib/release_me/bump_tag.rb +23 -24
- data/lib/release_me/bump_version.rb +13 -15
- data/lib/release_me/vcs_provider.rb +6 -7
- data/lib/release_me/version.rb +1 -1
- data/lib/release_me.rb +1 -3
- data/release_me.gemspec +14 -14
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a04f88cded4bd8423fd578a9a9db71d436fadb0
|
4
|
+
data.tar.gz: ac44cff967849b88c09b1e18ec758933571e4f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2ec983236aa57cb9482f22ea6fe129b1546a86ac74f8957c1ce411bfd8fb0e04d44d82f308920a563e0a641e5f87abcb4f111e7eafac03961ed984d72fb3ce
|
7
|
+
data.tar.gz: 54b0132ea5466abfb5139aedf06cf6a866bf748d738cd6ba13d75c3d38f3a60de4478c31c9bf5ce7fb23a7fc92de2f777beb5ed6e58bc28947ab152e899b7a4f
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
image: ruby:2.2
|
2
|
+
|
3
|
+
stages:
|
4
|
+
- validate
|
5
|
+
- test
|
6
|
+
- release
|
7
|
+
- deploy
|
8
|
+
|
9
|
+
run_test_suite:
|
10
|
+
stage: test
|
11
|
+
only:
|
12
|
+
- branches
|
13
|
+
tags:
|
14
|
+
- ruby2.2
|
15
|
+
script:
|
16
|
+
- bundle install
|
17
|
+
- bundle exec rake spec
|
18
|
+
|
19
|
+
rubocop_ruby:
|
20
|
+
stage: validate
|
21
|
+
allow_failure: true
|
22
|
+
tags:
|
23
|
+
- ruby2.2
|
24
|
+
script:
|
25
|
+
- bundle install
|
26
|
+
- bundle exec rubocop -D
|
27
|
+
|
28
|
+
bump_and_tag:
|
29
|
+
type: release
|
30
|
+
when: manual
|
31
|
+
tags:
|
32
|
+
- ruby2.2
|
33
|
+
only:
|
34
|
+
- master@nwops/release_me
|
35
|
+
script:
|
36
|
+
- bundle install
|
37
|
+
- bundle exec bump_and_tag
|
38
|
+
|
39
|
+
gem_production:
|
40
|
+
image: ruby:2.2
|
41
|
+
before_script:
|
42
|
+
- gem install dpl
|
43
|
+
stage: deploy
|
44
|
+
script:
|
45
|
+
- dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
|
46
|
+
only:
|
47
|
+
- tags
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-11-22 19:36:57 -0800 using RuboCop version 0.45.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 30
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: Exclude.
|
15
|
+
Style/Documentation:
|
16
|
+
Exclude:
|
17
|
+
- 'lib/release_me/version.rb'
|
18
|
+
|
19
|
+
# Offense count: 1
|
20
|
+
# Configuration parameters: AllowSafeAssignment.
|
21
|
+
Lint/AssignmentInCondition:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/release_me/vcs_provider.rb'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
|
28
|
+
# SupportedStyles: keyword, variable, start_of_line
|
29
|
+
Lint/EndAlignment:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/release_me/adapter.rb'
|
32
|
+
|
33
|
+
# Offense count: 1
|
34
|
+
Lint/Eval:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/release_me/adapter.rb'
|
37
|
+
|
38
|
+
# Offense count: 2
|
39
|
+
Lint/UselessAssignment:
|
40
|
+
Exclude:
|
41
|
+
- 'lib/release_me/adapter.rb'
|
42
|
+
- 'lib/release_me/vcs_provider.rb'
|
43
|
+
|
44
|
+
# Offense count: 2
|
45
|
+
Metrics/AbcSize:
|
46
|
+
Max: 26
|
47
|
+
|
48
|
+
# Offense count: 21
|
49
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
|
50
|
+
# URISchemes: http, https
|
51
|
+
Metrics/LineLength:
|
52
|
+
Max: 315
|
53
|
+
|
54
|
+
# Offense count: 4
|
55
|
+
# Configuration parameters: CountComments.
|
56
|
+
Metrics/MethodLength:
|
57
|
+
Max: 25
|
58
|
+
|
59
|
+
# Offense count: 4
|
60
|
+
Style/Documentation:
|
61
|
+
Exclude:
|
62
|
+
- 'spec/**/*'
|
63
|
+
- 'test/**/*'
|
64
|
+
- 'lib/release_me/adapter.rb'
|
65
|
+
- 'lib/release_me/bump_tag.rb'
|
66
|
+
- 'lib/release_me/bump_version.rb'
|
67
|
+
- 'lib/release_me/vcs_provider.rb'
|
68
|
+
|
69
|
+
# Offense count: 1
|
70
|
+
# Configuration parameters: MinBodyLength.
|
71
|
+
Style/GuardClause:
|
72
|
+
Exclude:
|
73
|
+
- 'lib/release_me/adapter.rb'
|
data/README.md
CHANGED
@@ -18,6 +18,34 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
### Gitlab and Gitlab CI
|
22
|
+
In gitlab you can create a task similar to the following.
|
23
|
+
|
24
|
+
```
|
25
|
+
bump_and_tag:
|
26
|
+
type: release
|
27
|
+
when: manual
|
28
|
+
tags:
|
29
|
+
- ruby2.2
|
30
|
+
only:
|
31
|
+
- master@above_on/above
|
32
|
+
script:
|
33
|
+
- bundle install
|
34
|
+
- bundle exec bump_and_tag
|
35
|
+
|
36
|
+
write_checksum:
|
37
|
+
type: release
|
38
|
+
when: manual
|
39
|
+
tags:
|
40
|
+
- ruby2.2
|
41
|
+
only:
|
42
|
+
- master@nwops/release_me
|
43
|
+
script:
|
44
|
+
- bundle install
|
45
|
+
- bundle exec bump_and_tag
|
46
|
+
|
47
|
+
```
|
48
|
+
|
21
49
|
### Local Release_me config
|
22
50
|
|
23
51
|
```
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'release_me'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "release_me"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/exe/bump_and_tag
CHANGED
data/exe/bump_version
CHANGED
data/lib/release_me/adapter.rb
CHANGED
@@ -5,13 +5,12 @@ require 'erb'
|
|
5
5
|
|
6
6
|
module ReleaseMe
|
7
7
|
module Adapter
|
8
|
-
|
9
8
|
# @return [Hash] - adapter config
|
10
9
|
# @param [String] - path to the directory in which you want to check
|
11
10
|
def adapter_config(project_path = Dir.pwd)
|
12
11
|
path = project_path || Dir.pwd
|
13
12
|
config = local_config(path) || detect_adapter_config(path)
|
14
|
-
raise
|
13
|
+
raise 'Cannot find config' if config.nil?
|
15
14
|
adapter = OpenStruct.new(config)
|
16
15
|
adapter[:version_file] = version_file(adapter, path)
|
17
16
|
adapter[:current_version] = current_version(adapter, adapter[:version_file])
|
@@ -26,7 +25,7 @@ module ReleaseMe
|
|
26
25
|
# @param [String] - path to the directory in which you want to check
|
27
26
|
def local_config(path = Dir.pwd)
|
28
27
|
file = File.join(path, '.release_me.yaml')
|
29
|
-
if File.
|
28
|
+
if File.exist?(file)
|
30
29
|
data = load_adapter(file)
|
31
30
|
data.fetch('adapter', nil)
|
32
31
|
end
|
@@ -43,23 +42,21 @@ module ReleaseMe
|
|
43
42
|
def current_version(adapter, file)
|
44
43
|
file_type = File.extname(file).downcase
|
45
44
|
case file_type
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
nil
|
56
|
-
end
|
45
|
+
when '.json'
|
46
|
+
JSON.parse(File.read(file))[adapter.version_field]
|
47
|
+
when '.yaml', '.yml'
|
48
|
+
YAML.load_file(file)[adapter.version_field]
|
49
|
+
when '.rb'
|
50
|
+
# reads in the ruby version file and should return the version if
|
51
|
+
# that is the last thing executed
|
52
|
+
eval(File.read(file))
|
53
|
+
end
|
57
54
|
end
|
58
55
|
|
59
56
|
# @return [Hash] - adapter config type
|
60
57
|
# @param [String] - path to the directory in which you want to check
|
61
58
|
def detect_adapter_config(path = Dir.pwd)
|
62
|
-
type, config = adapters.find do |
|
59
|
+
type, config = adapters.find do |_, adapter_config|
|
63
60
|
pattern = File.join(path, adapter_config['detection_pattern']) || ''
|
64
61
|
Dir.glob(pattern).count > 0
|
65
62
|
end
|
@@ -79,7 +76,7 @@ module ReleaseMe
|
|
79
76
|
unless @adapters
|
80
77
|
@adapters = {}
|
81
78
|
dir = File.join(File.dirname(File.expand_path(__FILE__)), 'adapters')
|
82
|
-
files =
|
79
|
+
files = Dir.glob(File.join(dir, '*.yaml'))
|
83
80
|
files.each do |file_name|
|
84
81
|
data = load_adapter(file_name)
|
85
82
|
@adapters[data['adapter_name']] = data
|
data/lib/release_me/bump_tag.rb
CHANGED
@@ -9,8 +9,8 @@ module ReleaseMe
|
|
9
9
|
def initialize(options)
|
10
10
|
@options = options
|
11
11
|
opts = {
|
12
|
-
|
13
|
-
|
12
|
+
json: true,
|
13
|
+
version: options[:version_type]
|
14
14
|
}
|
15
15
|
@version_instance = ReleaseMe::BumpVersion.new(opts)
|
16
16
|
end
|
@@ -42,28 +42,28 @@ module ReleaseMe
|
|
42
42
|
|
43
43
|
def file_update_body_request(file_contents, message)
|
44
44
|
{
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
id: vcs_config.project_id,
|
46
|
+
branch_name: vcs_config.branch_name,
|
47
|
+
author_email: vcs_config.author_email,
|
48
|
+
author_name: vcs_config.author_name,
|
49
|
+
commit_message: message,
|
50
|
+
actions: [
|
51
|
+
{
|
52
|
+
action: :update,
|
53
|
+
file_path: version_instance.app_version_file.gsub(Dir.pwd + '/', ''),
|
54
|
+
content: file_contents
|
55
|
+
}
|
56
|
+
]
|
57
57
|
}.to_json
|
58
58
|
end
|
59
59
|
|
60
60
|
def tag_body_request(tag_name, commit_id)
|
61
61
|
{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
id: vcs_config.project_id,
|
63
|
+
tag_name: tag_name,
|
64
|
+
ref: commit_id, # or git rev-parse HEAD
|
65
|
+
# messasge:
|
66
|
+
# release_description:
|
67
67
|
}.to_json
|
68
68
|
end
|
69
69
|
|
@@ -98,10 +98,10 @@ module ReleaseMe
|
|
98
98
|
# Don't verify
|
99
99
|
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE if vcs_config.no_verify
|
100
100
|
request = case method
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
when :put
|
102
|
+
Net::HTTP::Put.new(uri.path)
|
103
|
+
else
|
104
|
+
Net::HTTP::Post.new(uri.path)
|
105
105
|
end
|
106
106
|
request.body = body
|
107
107
|
# private token is specific to gitlab and must be set
|
@@ -129,6 +129,5 @@ module ReleaseMe
|
|
129
129
|
end
|
130
130
|
"Tagged: #{version_output['new_version']}"
|
131
131
|
end
|
132
|
-
|
133
132
|
end
|
134
133
|
end
|
@@ -27,16 +27,16 @@ module ReleaseMe
|
|
27
27
|
|
28
28
|
def new_version
|
29
29
|
unless @new_version
|
30
|
-
case version_type
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
@new_version = case version_type
|
31
|
+
when :commit
|
32
|
+
`git rev-parse HEAD`.chomp[0..8]
|
33
|
+
when :time
|
34
|
+
Time.now.strftime('%Y.%m.%d.%H%M')
|
35
|
+
when :semver
|
36
|
+
app_config.current_version.next
|
37
|
+
else
|
38
|
+
options[:version] || app_config.current_version.next
|
39
|
+
end
|
40
40
|
end
|
41
41
|
@new_version
|
42
42
|
end
|
@@ -47,9 +47,9 @@ module ReleaseMe
|
|
47
47
|
debug_message = "updated version string from #{app_config.current_version} to #{new_version}"
|
48
48
|
if options[:json]
|
49
49
|
output = JSON.pretty_generate(message: debug_message,
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
file_content: app_config_lines,
|
51
|
+
new_version: new_version,
|
52
|
+
old_version: app_config.current_version)
|
53
53
|
else
|
54
54
|
STDERR.puts debug_message
|
55
55
|
File.write(app_config.version_file, app_config_lines) unless options[:dry_run]
|
@@ -59,5 +59,3 @@ module ReleaseMe
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
63
|
-
|
@@ -4,13 +4,12 @@ require 'ostruct'
|
|
4
4
|
|
5
5
|
module ReleaseMe
|
6
6
|
module VcsProvider
|
7
|
-
|
8
7
|
# @return [Hash] - adapter config
|
9
8
|
# @param [String] - path to the directory in which you want to check
|
10
9
|
def provider_config(project_path = Dir.pwd)
|
11
10
|
path = project_path || Dir.pwd
|
12
11
|
config = local_config(path) || detect_provider_config
|
13
|
-
raise
|
12
|
+
raise 'Cannot find config' if config.nil?
|
14
13
|
if vcs = config.fetch('vcs', nil)
|
15
14
|
pdata = provider_data(vcs['provider'])
|
16
15
|
config = pdata.merge(vcs) # merge and override the default provider data
|
@@ -28,7 +27,7 @@ module ReleaseMe
|
|
28
27
|
# @param [String] - path to the directory in which you want to check
|
29
28
|
def local_config(path = Dir.pwd)
|
30
29
|
file = File.join(path, '.release_me.yaml')
|
31
|
-
load_provider(file) if File.
|
30
|
+
load_provider(file) if File.exist?(file)
|
32
31
|
end
|
33
32
|
|
34
33
|
# @param [String] path to adapter file
|
@@ -42,8 +41,8 @@ module ReleaseMe
|
|
42
41
|
# @return [Hash] - adapter config type
|
43
42
|
# @param [String] - path to the directory in which you want to check
|
44
43
|
def detect_provider_config
|
45
|
-
type, config = providers.find do |
|
46
|
-
c['detected']
|
44
|
+
type, config = providers.find do |_, c|
|
45
|
+
c['detected'] # return first provider that could be used
|
47
46
|
end
|
48
47
|
config
|
49
48
|
end
|
@@ -56,7 +55,7 @@ module ReleaseMe
|
|
56
55
|
def providers
|
57
56
|
unless @providers
|
58
57
|
@providers = {}
|
59
|
-
files =
|
58
|
+
files = Dir.glob(File.join(provider_dir, '*.yaml'))
|
60
59
|
files.each do |file_name|
|
61
60
|
data = load_provider(file_name)
|
62
61
|
@providers[data['provider_name']] = data
|
@@ -65,4 +64,4 @@ module ReleaseMe
|
|
65
64
|
@providers
|
66
65
|
end
|
67
66
|
end
|
68
|
-
end
|
67
|
+
end
|
data/lib/release_me/version.rb
CHANGED
data/lib/release_me.rb
CHANGED
data/release_me.gemspec
CHANGED
@@ -4,15 +4,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'release_me/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'release_me'
|
8
8
|
spec.version = ReleaseMe::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Corey Osman']
|
10
|
+
spec.email = ['corey@nwops.io']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = 'Release related scripts for any type of code'
|
13
|
+
spec.description = 'Automation scripts that help you release code'
|
14
|
+
spec.homepage = 'https://github.com/nwops/release_me'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -26,13 +26,13 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
27
|
f.match(%r{^(test|spec|features)/})
|
28
28
|
end
|
29
|
-
spec.bindir =
|
29
|
+
spec.bindir = 'exe'
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = [
|
32
|
-
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
-
spec.add_development_dependency "pry"
|
31
|
+
spec.require_paths = ['lib']
|
37
32
|
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
|
+
spec.add_development_dependency 'pry'
|
37
|
+
spec.add_development_dependency 'rubocop'
|
38
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: release_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Osman
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Automation scripts that help you release code
|
70
84
|
email:
|
71
85
|
- corey@nwops.io
|
@@ -76,8 +90,10 @@ extensions: []
|
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
92
|
- ".gitignore"
|
93
|
+
- ".gitlab-ci.yml"
|
79
94
|
- ".release_me.yaml"
|
80
95
|
- ".rspec"
|
96
|
+
- ".rubocop.yml"
|
81
97
|
- ".travis.yml"
|
82
98
|
- CODE_OF_CONDUCT.md
|
83
99
|
- Gemfile
|
@@ -119,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
135
|
version: '0'
|
120
136
|
requirements: []
|
121
137
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.8
|
123
139
|
signing_key:
|
124
140
|
specification_version: 4
|
125
141
|
summary: Release related scripts for any type of code
|