forked from choria-legacy/marionette-collective
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
109 lines (91 loc) · 2.47 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
RAKE_ROOT = File.expand_path(File.dirname(__FILE__))
# Allow override of RELEASE using BUILD_NUMBER
ENV["RELEASE"] = ENV["BUILD_NUMBER"] if ENV["BUILD_NUMBER"]
begin
load File.join(RAKE_ROOT, 'ext', 'packaging.rake')
rescue LoadError
end
def announce(msg='')
STDERR.puts "================"
STDERR.puts msg
STDERR.puts "================"
end
def safe_system *args
raise RuntimeError, "Failed: #{args.join(' ')}" unless system(*args)
end
def load_tools
unless File.directory?(File.join(RAKE_ROOT, 'ext', 'packaging'))
Rake::Task["package:bootstrap"].invoke
begin
load File.join(RAKE_ROOT, 'ext', 'packaging.rake')
rescue LoadError
STDERR.puts "Could not load packaging tools. exiting"
exit 1
end
end
end
def move_artifacts
mv("pkg", "build")
end
desc "Cleanup"
task :clean do
rm_rf "build"
rm_rf "doc"
end
desc "Create the .debs"
task :deb => :clean do
load_tools
announce("Building debian packages for #{@build.project}-#{@build.version}-#{@build.release}")
Rake::Task["package:deb"].invoke
if ENV['SIGNED'] == '1'
deb_flag = "-k#{ENV['SIGNWITH']}" if ENV['SIGNWITH']
safe_system %{/usr/bin/debsign #{deb_flag} pkg/deb/*.changes}
end
move_artifacts
end
desc "Build documentation"
task :doc => :clean do
load_tools
Rake::Task["package:doc"].invoke
end
desc "Build a gem"
task :gem => :clean do
load_tools
Rake::Task["gem"].reenable
Rake::Task["package:gem"].invoke
end
desc "Create a tarball for this release"
task :package => :clean do
load_tools
announce "Creating #{@build.project}-#{@build.version}.tar.gz"
Rake::Task["package:tar"].invoke
move_artifacts
end
desc "Creates a RPM"
task :rpm => :clean do
load_tools
announce("Building RPM for #{@build.project}-#{@build.version}-#{@build.release}")
Rake::Task["package:rpm"].invoke
Rake::Task["package:srpm"].invoke
if ENV['SIGNED'] == '1'
safe_system %{/usr/bin/rpm --sign pkg/**/*.rpm}
end
move_artifacts
end
desc "Run spec tests"
task :test do
sh "cd spec && rake"
end
desc "Creates the website as a tarball"
task :website => :clean do
FileUtils.mkdir_p("build/marionette-collective.org/html")
Dir.chdir("website") do
safe_system("jekyll ../build/marionette-collective.org/html")
end
unless File.exist?("build/marionette-collective.org/html/index.html")
raise "Failed to build website"
end
Dir.chdir("build") do
safe_system("tar -cvzf marionette-collective-org-#{Time.now.to_i}.tgz marionette-collective.org")
end
end