-
Notifications
You must be signed in to change notification settings - Fork 104
/
Rakefile
136 lines (112 loc) · 3.35 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
require 'rspec/core/rake_task'
require 'rake/packagetask'
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
require 'liftoff/version'
GEMS_DIR = 'vendor/gems'
GH_PAGES_DIR = 'gh-pages'
HOMEBREW_FORMULAE_DIR = 'homebrew-formulae'
namespace :gems do
desc 'Vendorize dependencies'
task :vendorize do
system('vendor/vendorize', GEMS_DIR)
end
desc 'Remove vendorized dependencies'
task :clean do
if Dir.exists?(GEMS_DIR)
FileUtils.rm_r(GEMS_DIR)
end
end
end
desc 'Push new release'
task :release => ['release:build', 'release:push', 'release:clean']
namespace :release do
desc 'Build a new release'
task :build => ['tarball:build', 'homebrew:build']
desc 'Push sub-repositories'
task :push => ['tarball:push', 'homebrew:push']
desc 'Clean all build artifacts'
task :clean => ['gems:clean', 'tarball:clean', 'homebrew:clean']
end
namespace :homebrew do
desc 'Generate homebrew formula and add it to the repo'
task :build => ['checkout', 'formula:build', 'commit']
desc 'Checkout homebrew repo locally'
task :checkout do
`git clone [email protected]:liftoffcli/homebrew-formulae.git #{HOMEBREW_FORMULAE_DIR}`
end
desc 'Check in the new Homebrew formula'
task :commit do
Dir.chdir(HOMEBREW_FORMULAE_DIR) do
`git add Formula/liftoff.rb`
`git commit -m "liftoff: Release version #{Liftoff::VERSION}"`
end
end
desc 'Push homebrew repo'
task :push do
Dir.chdir(HOMEBREW_FORMULAE_DIR) do
`git push`
end
end
desc 'Remove Homebrew repo'
task :clean do
if Dir.exists?(HOMEBREW_FORMULAE_DIR)
FileUtils.rm_rf(HOMEBREW_FORMULAE_DIR)
end
end
namespace :formula do
desc 'Build homebrew formula'
task :build do
formula = File.read('homebrew/liftoff.rb')
formula.gsub!('__VERSION__', Liftoff::VERSION)
formula.gsub!('__SHA__', `shasum -a 256 #{GH_PAGES_DIR}/Liftoff-#{Liftoff::VERSION}.tar.gz`.split.first)
File.write("#{HOMEBREW_FORMULAE_DIR}/Formula/liftoff.rb", formula)
end
end
end
namespace :tarball do
desc 'Build the tarball'
task :build => ['checkout', 'package', 'move', 'commit']
desc 'Checkout gh-pages'
task :checkout do
`git clone --branch gh-pages [email protected]:liftoffcli/liftoff.git #{GH_PAGES_DIR}`
end
desc 'Move tarball into gh-pages'
task :move do
FileUtils.mv("pkg/Liftoff-#{Liftoff::VERSION}.tar.gz", GH_PAGES_DIR)
end
desc 'Check in the new tarball'
task :commit do
Dir.chdir(GH_PAGES_DIR) do
`git add Liftoff-#{Liftoff::VERSION}.tar.gz`
`git commit -m "Release version #{Liftoff::VERSION}"`
end
end
desc 'Push the gh-pages branch'
task :push do
Dir.chdir(GH_PAGES_DIR) do
`git push`
end
end
desc 'Remove gh-pages and pkg directories'
task :clean do
if Dir.exists?(GH_PAGES_DIR)
FileUtils.rm_rf(GH_PAGES_DIR)
end
if Dir.exists?('pkg')
FileUtils.rm_rf('pkg')
end
end
Rake::PackageTask.new('Liftoff', Liftoff::VERSION) do |p|
p.need_tar_gz = true
p.package_files.include('src/**/*')
p.package_files.include('defaults/**/*')
p.package_files.include('lib/**/*')
p.package_files.include('templates/**/*')
p.package_files.include('vendor/**/*')
p.package_files.include('man/**/*')
p.package_files.include('LICENSE.txt')
end
end
desc 'Run tests'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec