puppet-blacksmith 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/puppet_blacksmith/rake_tasks.rb +93 -50
  2. metadata +75 -82
@@ -7,75 +7,118 @@ require 'nokogiri'
7
7
  namespace :module do
8
8
  desc "Bump module version to the next minor"
9
9
  task :bump do
10
- m = modulefile()
11
- text = File.read("Modulefile")
12
- v = increase_version(m.version)
13
- puts "Bumping version from #{m.version} to #{v}"
14
- text = replace_version(text, v)
15
- File.open("Modulefile", "w") {|file| file.puts text}
10
+ bump
16
11
  end
17
12
 
18
13
  desc "Git tag with the current module version"
19
14
  task :tag do
20
- m = modulefile()
21
- sh "git tag v#{m.version}"
15
+ tag
22
16
  end
23
17
 
24
18
  desc "Bump version and git commit"
25
19
  task :bump_commit => :bump do
26
- sh "git add Modulefile"
27
- sh "git commit -m 'Bump version'"
20
+ bump_commit
28
21
  end
29
22
 
30
23
  desc "Push module to the Puppet Forge"
31
24
  task :push => :build do
32
- RestClient.proxy = ENV['http_proxy']
33
- credentials_file = File.expand_path("~/.puppetforge.yml")
34
- unless File.exists?(credentials_file)
35
- fail("Could not find Puppet Forge credentials file '#{credentials_file}'
25
+ push
26
+ end
27
+
28
+ desc "Runs clean again"
29
+ task :clean do
30
+ puts "Cleaning for module build"
31
+ Rake::Task["clean"].execute
32
+ end
33
+
34
+ desc "Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push."
35
+ task :release => [:clean, :build, :tag, :push, :bump_commit] do
36
+ puts "Pushing commits to remote git repo"
37
+ sh "git push"
38
+ puts "Pushing tags to remote git repo"
39
+ sh "git push --tags"
40
+ end
41
+ end
42
+
43
+
44
+ # task methods for reuse
45
+
46
+ def bump
47
+ m = modulefile()
48
+ text = File.read("Modulefile")
49
+ v = increase_version(m.version)
50
+ puts "Bumping version from #{m.version} to #{v}"
51
+ text = replace_version(text, v)
52
+ File.open("Modulefile", "w") {|file| file.puts text}
53
+ end
54
+
55
+ def tag
56
+ m = modulefile()
57
+ sh "git tag v#{m.version}"
58
+ end
59
+
60
+ def bump_commit
61
+ sh "git add Modulefile"
62
+ sh "git commit -m 'Bump version'"
63
+ end
64
+
65
+ def bump_commit_push
66
+ sh "git add Modulefile"
67
+ sh "git commit -m 'Bump version'"
68
+ end
69
+
70
+ def push
71
+ RestClient.proxy = ENV['http_proxy']
72
+ credentials_file = File.expand_path("~/.puppetforge.yml")
73
+ unless File.exists?(credentials_file)
74
+ fail(<<-eos)
75
+ Could not find Puppet Forge credentials file '#{credentials_file}'
36
76
  Please create it
37
77
  ---
38
78
  forge: https://forge.puppetlabs.com
39
79
  username: myuser
40
- password: mypassword")
41
- end
42
- credentials = YAML.load_file(credentials_file)
43
- m = modulefile("Modulefile")
44
- forge = credentials['forge'] || "https://forge.puppetlabs.com"
45
-
46
- # login to the puppet forge
47
- puts "Logging into Puppet Forge as user #{credentials['username']}"
48
- response = RestClient.post(
49
- "#{forge}/login",
50
- {'username' => credentials['username'], 'password' => credentials['password']}){
51
- |response, request, result, &block|
52
- if [301, 302, 307].include? response.code
53
- response
54
- else
55
- response.return!(request, result, &block)
56
- end
57
- }
58
- fail("Failed to login to Puppet Forge: cookies not set correctly") unless response.cookies['auth']
59
-
60
- # upload the file
61
- package = "pkg/#{m.username}-#{m.name}-#{m.version}.tar.gz"
62
- puts "Uploading #{package} to Puppet Forge #{m.username}/#{m.name}"
63
- response = RestClient.post("#{forge}/#{m.username}/#{m.name}/upload",
64
- {:tarball => File.new(package, 'rb')},
65
- {:cookies => response.cookies}){
66
- |response, request, result, &block|
67
- if [301, 302, 307].include? response.code
68
- response
69
- else
70
- response.return!(request, result, &block)
71
- end
72
- }
73
- page = Nokogiri::HTML(response.body)
74
- errors = page.css('.errors')
75
- fail("Error uploading module #{package} to Puppet Forge #{m.username}/#{m.name}:#{errors.text}") unless errors.empty?
80
+ password: mypassword
81
+ eos
76
82
  end
83
+ credentials = YAML.load_file(credentials_file)
84
+ m = modulefile("Modulefile")
85
+ forge = credentials['forge'] || "https://forge.puppetlabs.com"
86
+
87
+ # login to the puppet forge
88
+ puts "Logging into Puppet Forge as user #{credentials['username']}"
89
+ response = RestClient.post(
90
+ "#{forge}/login",
91
+ {'username' => credentials['username'], 'password' => credentials['password']}){
92
+ |response, request, result, &block|
93
+ if [301, 302, 307].include? response.code
94
+ response
95
+ else
96
+ response.return!(request, result, &block)
97
+ end
98
+ }
99
+ fail("Failed to login to Puppet Forge: cookies not set correctly") unless response.cookies['auth']
100
+
101
+ # upload the file
102
+ package = "pkg/#{m.username}-#{m.name}-#{m.version}.tar.gz"
103
+ puts "Uploading #{package} to Puppet Forge #{m.username}/#{m.name}"
104
+ response = RestClient.post("#{forge}/#{m.username}/#{m.name}/upload",
105
+ {:tarball => File.new(package, 'rb')},
106
+ {:cookies => response.cookies}){
107
+ |response, request, result, &block|
108
+ if [301, 302, 307].include? response.code
109
+ response
110
+ else
111
+ response.return!(request, result, &block)
112
+ end
113
+ }
114
+ page = Nokogiri::HTML(response.body)
115
+ errors = page.css('.errors')
116
+ fail("Error uploading module #{package} to Puppet Forge #{m.username}/#{m.name}:#{errors.text}") unless errors.empty?
77
117
  end
78
118
 
119
+
120
+ # util
121
+
79
122
  def replace_version(text, version)
80
123
  text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'")
81
124
  end
metadata CHANGED
@@ -1,149 +1,142 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: puppet-blacksmith
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
4
5
  prerelease:
5
- version: 1.0.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - MaestroDev
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2013-02-06 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rake
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &12387780 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *12387780
25
+ - !ruby/object:Gem::Dependency
27
26
  name: rest-client
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &12386620 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *12386620
36
+ - !ruby/object:Gem::Dependency
38
37
  name: puppet
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &12421260 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
44
43
  version: 2.7.16
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *12421260
47
+ - !ruby/object:Gem::Dependency
49
48
  name: puppetlabs_spec_helper
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &12418920 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
55
54
  version: 0.3.0
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *12418920
58
+ - !ruby/object:Gem::Dependency
60
59
  name: nokogiri
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &12417620 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
67
66
  type: :runtime
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *12417620
69
+ - !ruby/object:Gem::Dependency
71
70
  name: cucumber
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &12416140 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *12416140
80
+ - !ruby/object:Gem::Dependency
82
81
  name: aruba
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &12414740 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *12414740
91
+ - !ruby/object:Gem::Dependency
93
92
  name: rspec
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &12559120 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
99
98
  version: 2.7.0
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
101
+ version_requirements: *12559120
103
102
  description: Puppet module tools for development and Puppet Forge management
104
- email:
103
+ email:
105
104
  - info@maestrodev.com
106
105
  executables: []
107
-
108
106
  extensions: []
109
-
110
107
  extra_rdoc_files: []
111
-
112
- files:
108
+ files:
113
109
  - lib/puppet_blacksmith/rake_tasks.rb
114
110
  - LICENSE
115
111
  - spec/puppet_blacksmith/rake_tasks_spec.rb
116
112
  - spec/data/Modulefile
117
113
  homepage: http://github.com/maestrodev/puppet-blacksmith
118
114
  licenses: []
119
-
120
115
  post_install_message:
121
116
  rdoc_options: []
122
-
123
- require_paths:
117
+ require_paths:
124
118
  - lib
125
- required_ruby_version: !ruby/object:Gem::Requirement
119
+ required_ruby_version: !ruby/object:Gem::Requirement
126
120
  none: false
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- hash: 1236692396911248610
131
- segments:
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
132
126
  - 0
133
- version: "0"
134
- required_rubygems_version: !ruby/object:Gem::Requirement
127
+ hash: -2324545101189307236
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
129
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
140
134
  requirements: []
141
-
142
135
  rubyforge_project:
143
136
  rubygems_version: 1.8.6
144
137
  signing_key:
145
138
  specification_version: 3
146
139
  summary: Tasks to manage Puppet module builds
147
- test_files:
140
+ test_files:
148
141
  - spec/puppet_blacksmith/rake_tasks_spec.rb
149
142
  - spec/data/Modulefile