-
Notifications
You must be signed in to change notification settings - Fork 23
/
Rakefile
81 lines (67 loc) · 2.29 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -----------------------------------------------------------------------------
# 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: ['lint'] 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
# -----------------------------------------------------------------------------
# Style
# -----------------------------------------------------------------------------
namespace 'style' do
require 'cookstyle'
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:cookstyle)
end
# -----------------------------------------------------------------------------
# Stove
# -----------------------------------------------------------------------------
namespace 'stove' do
require 'stove/rake_task'
# Credentials are stored in ~/.stove
Stove::RakeTask.new do |t|
t.stove_opts = ['--no-git']
end
end
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
desc 'Run linters'
task lint: ['style:cookstyle']
desc 'Release new cookbook version'
task release: [
'berkshelf:update', 'git:release', 'berkshelf:upload', 'stove:publish'
]
desc 'Upload released cookbook to Chef Server'
task upload: ['berkshelf:update', 'berkshelf:upload']
task default: :release