cookbook-release 0.3.1 → 0.4.1

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e16de633b17c5ed9330aa52a064e28f1f3137c1
4
- data.tar.gz: 0e622fbfd16fdbbc72cb33d4c2d8d49037c27515
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTI4ODkyNzExM2I1YWMyZGJiYjliMWY0YTMwYmRlMWIzNDMyMTRjZA==
5
+ data.tar.gz: !binary |-
6
+ NjQyZmEzMDQxNWNmYzc3NmNhODQyODk0N2ZiNjFlZDljMTQ4YmZmYQ==
5
7
  SHA512:
6
- metadata.gz: 300f1ef19d91db02acafd02474d7f46619205dcb9653b814cbccc2f1d45fd83e1e88c9d4fa4f1662a82d65bf6c904670c0965e7539b2ac64a780494ab5b76890
7
- data.tar.gz: 03feb35e48cc03df23754f34ccc0fd0f01a3d7877ab1fc0cc01c88cb22b825a2cc37db80807d6dc6b4943feeda181ca20c3ab635e306390da7604b67a850b1ee
8
+ metadata.gz: !binary |-
9
+ NDNiYTdjNzBlNTllZTliYzAxNDViZDc2Y2Q0NTMxYWMxMDQzMWE1OWE2NDgz
10
+ YWI5ZjUxNTc0ZGQ0MTJlY2FkZjk2OWE1MGM2NzA1OTBjMWMxZjMwMTI4MWEx
11
+ NDdlZjg2OGUzZDEyMGUzNTA5NDZiMmUxZWFkYWJkNDE4YWEwNjg=
12
+ data.tar.gz: !binary |-
13
+ NTM4MzgzMDdiMTA5OWMzMzNjZDViN2RiNmNkNzUyYzI1MGVmY2EzYjk1MTlj
14
+ OWZmNzlhOGRlMTZmNzU0MWFmM2ExOWE0YmRkYmVlZWE4MDljODEyNGUwNTk4
15
+ Zjk5NTQyYWE0MjU4OTA2MTliOTIxMTFmYzZlODY2YWZhNzQyNWY=
@@ -1,10 +1,10 @@
1
1
  language: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y2mVeSe67fBPVDopAEGij7MNJCBWV1/SRRKQcEb2U823+1GSB13OvaOGTn9rYsJP5zLKu77ATbHPi22nMfWOAzdEJJ+uFu9XW4nwUO/j79zPC1mEsRZDJlDrmTc4XZQJRKkCUjSl/J53vbdy4JQfos8B2V15tzx1baswQVPZuNiwuP4dOupI34FohJSVXQrsOoWVWVEX5Tfod6s3kpivW6lzwM68I2qXFa/4H8RPU2m0eVpfQslOO8TaGnbodudbQ1LSi/d5W6XWrMVqWGH910JG3jlJgHn5J7yQlI4VqnOpCjGsx/5xincuJZ7hBhcu5q5zcAGem7TrYSNkrx6neBYKmpZBHOWalIGw8wI9uViEsGQ6fayFee8=
8
8
  gem: cookbook-release
9
9
  on:
10
10
  tags: true
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  CookbookRelease
2
2
  ===============
3
3
 
4
+ [![Build Status](https://travis-ci.org/criteo/cookbook-release.svg?branch=master)](https://travis-ci.org/criteo/cookbook-release)
5
+ [![Gem Version](https://badge.fury.io/rb/cookbook-release.svg)](https://badge.fury.io/rb/cookbook-release)
6
+
4
7
  Helper to release cookbooks. This motivation is to publish new version at each commit on master branch from the CI.
5
8
 
6
9
  This helper will create tags, push them and publish to supermarket.
@@ -33,4 +36,10 @@ export NO_PROMPT=""
33
36
  rake release!
34
37
  ```
35
38
 
39
+ Optional environment variables:
40
+
41
+ ```
42
+ export COOKBOOK_CATEGORY="Other" # defaults to Other
43
+ ```
44
+
36
45
  Note: this setup is intended to be used in a CI system such as jenkins or travis.
@@ -6,7 +6,7 @@ require 'English'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'cookbook-release'
9
- spec.version = '0.3.1'
9
+ spec.version = '0.4.1'
10
10
  spec.authors = ['Grégoire Seux']
11
11
  spec.email = 'g.seux@criteo.com'
12
12
  spec.summary = 'Provide primitives (and rake tasks) to release a cookbook'
@@ -19,7 +19,8 @@ module CookbookRelease
19
19
  desc "Prepare cookbook release and push tag to git"
20
20
  task "release!" do
21
21
  opts = {
22
- no_prompt: ENV['NO_PROMPT']
22
+ no_prompt: ENV['NO_PROMPT'],
23
+ category: ENV['COOKBOOK_CATEGORY'],
23
24
  }
24
25
  git = GitUtilities.new
25
26
  Release.new(git, opts).release!
@@ -8,7 +8,10 @@ class GitUtilities
8
8
  attr_accessor :no_prompt
9
9
 
10
10
  def initialize(options={})
11
- @tag_prefix = options['tag_prefix'] || ''
11
+ @tag_prefix = options[:tag_prefix] || ''
12
+ @shellout_opts = {
13
+ cwd: options[:cwd]
14
+ }
12
15
  end
13
16
 
14
17
  def reset_command(new_version)
@@ -16,9 +19,9 @@ class GitUtilities
16
19
  end
17
20
 
18
21
  def clean_index?
19
- clean_index = Mixlib::ShellOut.new("git diff --exit-code")
22
+ clean_index = Mixlib::ShellOut.new("git diff --exit-code", @shellout_opts)
20
23
  clean_index.run_command
21
- clean_staged = Mixlib::ShellOut.new("git diff --exit-code --cached")
24
+ clean_staged = Mixlib::ShellOut.new("git diff --exit-code --cached", @shellout_opts)
22
25
  clean_staged.run_command
23
26
  !clean_index.error? && !clean_staged.error?
24
27
  end
@@ -33,18 +36,22 @@ class GitUtilities
33
36
  'git describe',
34
37
  "--tags",
35
38
  "--match \"#{@tag_prefix}[0-9]\.[0-9]*\.[0-9]*\""
36
- ].join " ")
39
+ ].join(" "), @shellout_opts)
37
40
  tag.run_command
38
41
  tag.stdout.split('-').first.to_version
39
42
  end
40
43
 
44
+ # This string is used to split one-line git commit summary
45
+ # it just needs to be unlikely in a commit message
46
+ MAGIC_SEP = '@+-+@+-+@+-+@'
47
+
41
48
  def compute_changelog(since)
42
49
  # TODO use whole commit message instead of title only
43
- log_cmd = Mixlib::ShellOut.new("git log --pretty='format:%an <%ae>::%s::%h' #{since}..HEAD")
50
+ log_cmd = Mixlib::ShellOut.new("git log --pretty='format:%an <%ae>#{MAGIC_SEP}%s#{MAGIC_SEP}%h' #{since}..HEAD", @shellout_opts)
44
51
  log_cmd.run_command
45
52
  log = log_cmd.stdout
46
53
  log.split("\n").map do |entry|
47
- author, subject, hash = entry.chomp.split("::")
54
+ author, subject, hash = entry.chomp.split(MAGIC_SEP)
48
55
  Commit.new({
49
56
  author: author,
50
57
  subject: subject,
@@ -54,13 +61,13 @@ class GitUtilities
54
61
  end
55
62
 
56
63
  def tag(version)
57
- cmd = Mixlib::ShellOut.new("git tag #{@tag_prefix}#{version}")
64
+ cmd = Mixlib::ShellOut.new("git tag #{@tag_prefix}#{version}", @shellout_opts)
58
65
  cmd.run_command
59
66
  cmd.error!
60
67
  end
61
68
 
62
69
  def choose_remote
63
- cmd = Mixlib::ShellOut.new("git remote")
70
+ cmd = Mixlib::ShellOut.new("git remote", @shellout_opts)
64
71
  cmd.run_command
65
72
  cmd.error!
66
73
  remotes = cmd.stdout.split("\n")
@@ -74,7 +81,7 @@ class GitUtilities
74
81
 
75
82
  def push_tag(version)
76
83
  remote = choose_remote
77
- cmd = Mixlib::ShellOut.new("git push #{remote} #{@tag_prefix}#{version}")
84
+ cmd = Mixlib::ShellOut.new("git push #{remote} #{@tag_prefix}#{version}", @shellout_opts)
78
85
  cmd.run_command
79
86
  cmd.error!
80
87
  end
@@ -1,7 +1,8 @@
1
1
  class Release
2
2
 
3
- def self.current_version
4
- r = Release.new(GitUtilities.new)
3
+ # file will be used to determine the git directory
4
+ def self.current_version(file)
5
+ r = Release.new(GitUtilities.new(cwd: File.dirname(file)))
5
6
  begin
6
7
  r.new_version.first
7
8
  rescue ExistingRelease
@@ -18,6 +19,7 @@ class Release
18
19
  @git = git
19
20
  @no_prompt = opts[:no_prompt]
20
21
  @git.no_prompt = @no_prompt
22
+ @category = opts[:category] || 'Other'
21
23
  end
22
24
 
23
25
  def last_release
@@ -83,10 +85,11 @@ class Release
83
85
  exit 1 unless agreed
84
86
  git.push_tag(new_version)
85
87
  supermarket = Supermarket.new
86
- supermarket.publish_ck('Others')
87
- ensure
88
+ supermarket.publish_ck(@category)
89
+ rescue
88
90
  puts HighLine.color("Release aborted, you have to reset to previous state manually", :red)
89
91
  puts ":use with care: #{git.reset_command(new_version)}"
92
+ raise
90
93
  end
91
94
  end
92
95
  end
@@ -19,6 +19,32 @@ describe Release do
19
19
  end
20
20
  end
21
21
 
22
+ describe '.release!' do
23
+ it 'calls category with a valid default category' do
24
+
25
+ c = double('c',
26
+ :major? => true,
27
+ :[] => '',
28
+ :color => :red,
29
+ )
30
+ git = double('git',
31
+ :clean_index! => true,
32
+ :compute_last_release => '1.0.0'.to_version,
33
+ :compute_changelog => [c],
34
+ :tag => true,
35
+ :push_tag => true,
36
+ )
37
+ allow(git).to receive(:no_prompt=)
38
+ release = Release.new(git, no_prompt: true)
39
+
40
+ supermarket = double('supermarket')
41
+ expect(Supermarket).to receive(:new).and_return(supermarket)
42
+
43
+ expect(supermarket).to receive(:publish_ck).with('Other')
44
+ release.release!
45
+ end
46
+ end
47
+
22
48
 
23
49
  describe '.new_version' do
24
50
 
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: highline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mixlib-shellout
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: chef
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec_junit_formatter
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - ! '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - ! '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: Provide primitives (and rake tasks) to release a cookbook
@@ -128,8 +128,8 @@ executables: []
128
128
  extensions: []
129
129
  extra_rdoc_files: []
130
130
  files:
131
- - ".gitignore"
132
- - ".travis.yml"
131
+ - .gitignore
132
+ - .travis.yml
133
133
  - Gemfile
134
134
  - LICENSE.txt
135
135
  - README.md
@@ -155,17 +155,17 @@ require_paths:
155
155
  - lib
156
156
  required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - ! '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ">="
163
+ - - ! '>='
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.5.1
168
+ rubygems_version: 2.4.5
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Provide primitives (and rake tasks) to release a cookbook
@@ -175,4 +175,3 @@ test_files:
175
175
  - spec/release_spec.rb
176
176
  - spec/spec_helper.rb
177
177
  - spec/supermarket_spec.rb
178
- has_rdoc: