forked from jwadolowski/cookbook-cq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
51 lines (43 loc) · 1.52 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -----------------------------------------------------------------------------
# Helpers
# -----------------------------------------------------------------------------
def cookbook_version
require 'chef/cookbook/metadata'
metadata = Chef::Cookbook::Metadata.new
metadata.from_file('metadata.rb')
metadata.version
end
# -----------------------------------------------------------------------------
# Berkshelf
# -----------------------------------------------------------------------------
namespace 'berkshelf' do
desc 'Update cookbook dependencies'
task :update do
sh 'berks update || berks install'
end
desc 'Upload cookbook to Chef Server'
task :upload do
sh 'berks upload --except development'
end
end
# -----------------------------------------------------------------------------
# Git
# -----------------------------------------------------------------------------
namespace 'git' do
desc 'Create new Git tag'
task :tag do
sh "git tag -a v#{cookbook_version} -m \"v#{cookbook_version} release\""
end
desc 'Push new tag to Git repository'
task :push do
sh "git push origin v#{cookbook_version}"
end
desc 'Create new tag and push it to Git repository'
task :release => [:tag, :push]
end
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
desc 'Release new cookbook version'
task :release => ['berkshelf:update', 'git:release', 'berkshelf:upload']
task default: :release