forked from wincent/command-t
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
195 lines (163 loc) · 4.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
require 'yaml'
def bail_on_failure
exitstatus = $?.exitstatus
if exitstatus != 0
err "last command failed with exit status #{exitstatus}"
exit 1
end
end
def version
`git describe`.chomp
end
def rubygems_version
# RubyGems will barf if we try to pass an intermediate version number
# like "1.1b2-10-g61a374a", so no choice but to abbreviate it
`git describe --abbrev=0`.chomp
end
def yellow
"\033[33m"
end
def red
"\033[31m"
end
def clear
"\033[0m"
end
def warn str
puts "#{yellow}warning: #{str}#{clear}"
end
def err str
puts "#{red}error: #{str}#{clear}"
end
def prepare_release_notes
# extract base release notes from README.txt HISTORY section
File.open('.release-notes.txt', 'w') do |out|
lines = File.readlines('README.txt').each { |line| line.chomp! }
while line = lines.shift do
next unless line =~ /^HISTORY +\*command-t-history\*$/
break unless lines.shift == '' &&
(line = lines.shift) && line =~ /^\d\.\d/ &&
lines.shift == ''
while line = lines.shift and line != ''
out.puts line
end
break
end
out.puts ''
out.puts '# Please edit the release notes to taste.'
out.puts '# Blank lines and lines beginning with a hash will be removed.'
out.puts '# To abort, exit your editor with a non-zero exit status (:cquit in Vim).'
end
unless system "$EDITOR .release-notes.txt"
err "editor exited with non-zero exit status; aborting"
exit 1
end
filtered = read_release_notes
File.open('.release-notes.txt', 'w') do |out|
out.print filtered
end
end
def read_release_notes
File.readlines('.release-notes.txt').reject do |line|
line =~ /^(#.*|\s*)$/ # filter comment lines and blank lines
end.join
end
task :default => :spec
desc 'Print help on preparing a release'
task :help do
puts <<-END
The general release sequence is:
rake prerelease
rake gem
rake push
rake upload:all
Note: the upload task depends on the Mechanize gem; and may require a
prior `gem install mechanize`
END
end
desc 'Run specs'
task :spec do
system 'bundle exec rspec spec'
bail_on_failure
end
desc 'Create vimball archive'
task :vimball => :check_tag do
system 'make'
bail_on_failure
FileUtils.cp 'command-t.vba', "command-t-#{version}.vba"
end
desc 'Clean compiled products'
task :clean do
Dir.chdir 'ruby/command-t' do
system 'make clean' if File.exists?('Makefile')
system 'rm -f Makefile'
end
end
desc 'Clobber all generated files'
task :clobber => :clean do
system 'make clean'
end
desc 'Compile extension'
task :make do
Dir.chdir 'ruby/command-t' do
ruby 'extconf.rb'
system 'make clean'
bail_on_failure
system 'make'
bail_on_failure
end
end
namespace :make do
desc 'Compile under all multiruby versions'
task :all do
system './compile-test.sh'
bail_on_failure
end
end
namespace :spec do
desc 'Run specs under all multiruby versions'
task :all do
system './multi-spec.sh'
bail_on_failure
end
end
desc 'Check that the current HEAD is tagged'
task :check_tag do
unless system 'git describe --exact-match HEAD 2> /dev/null'
warn 'current HEAD is not tagged'
end
end
desc 'Run checks prior to release'
task :prerelease => ['make:all', 'spec:all', :vimball, :check_tag]
namespace :upload do
desc 'Upload current vimball to Amazon S3'
task :s3 => :vimball do
sh 'aws --curl-options=--insecure put ' +
"s3.wincent.com/command-t/releases/command-t-#{version}.vba " +
"command-t-#{version}.vba"
sh 'aws --curl-options=--insecure put ' +
"s3.wincent.com/command-t/releases/command-t-#{version}.vba?acl " +
'--public'
end
desc 'Upload current vimball to www.vim.org'
task :vim => :vimball do
prepare_release_notes
sh "vendor/vimscriptuploader/vimscriptuploader.rb \
--id 3025 \
--file command-t-#{version}.vba \
--message-file .release-notes.txt \
--version #{version} \
--config ~/.vim_org.yml \
.vim_org.yml"
end
desc 'Upload current vimball everywhere'
task :all => [ :s3, :vim ]
end
desc 'Create the ruby gem package'
task :gem => :check_tag do
sh "gem build command-t.gemspec"
end
desc 'Push gem to Gemcutter ("gem push")'
task :push => :gem do
sh "gem push command-t-#{rubygems_version}.gem"
end