Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 206 lines (140 sloc) 4.442 kb
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
1
2 # Build the tar.gz, tar.bz2, and .gem files for an RMagick Release
3
7ac054f Polish
rmagick authored
4 # To use: cd to $HOME
5 # run: rake -f path/to/build_tarball.rake clean
6 # rake -f path/to/build_tarball.rake release=tag beta=whatever
7 #
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
8 # Specify the release as release=RMagick_x-y-z or nothing if release=HEAD
9 # Specify a beta Release as beta=beta1
10
11 require 'rubygems'
12 require 'bluecloth'
13 require 'find'
14 require 'fileutils'
15 include FileUtils
16
17
18 CVSSERVER = ":ext:rmagick@rubyforge.org/var/cvs/rmagick"
19
20
7ac054f Polish
rmagick authored
21 # CVS_Tag is the CVS tag for this release. Dist_Directory is CVS_Tag,
22 # modified for use as a directory name.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
23 if ENV.include?("release")
24 CVS_Tag = ENV["release"]
25 Dist_Directory = CVS_Tag.tr('_-','-.')
26 else
27 CVS_Tag = "HEAD"
28 Dist_Directory = "RMagick-0.0.0"
29 end
30
31
32 # RMagick_Version is just X.Y.Z
33 RMagick_Version = Dist_Directory.sub(/RMagick-/, "")
34
35 # RMagick_Version2 is X.Y.Z + "-beta1" if beta=beta1
36 RMagick_Version2 = RMagick_Version + (ENV.include?("beta") ? "-" + ENV["beta"] : "")
37
38 # Release is RMagick-X.Y.Z, plus "-beta1" if beta=beta1
39 Release = Dist_Directory + (ENV.include?("beta") ? "-" + ENV["beta"] : "")
40
41 README = "README.html"
42 MANIFEST = "ext/RMagick/MANIFEST"
43
44
45
46
7ac054f Polish
rmagick authored
47 # Change the version number placeholders in a file.
48 # Returns an array of lines from the file.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
49 def reversion(name)
50 now = Time.new
51 now = now.strftime("%m/%d/%y")
52
53 lines = File.readlines name
54 lines.each do |line|
55 line.gsub!(%r{0\.0\.0\$}, RMagick_Version2)
56 line.gsub!(%r{0\.0\.0}, RMagick_Version)
57 line.gsub!(%r{YY/MM/DD}, now)
58 end
59 lines
60 end
61
62
63
64
7ac054f Polish
rmagick authored
65 # Rewrite a file containing embedded version number placeholders.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
66 def reversion_file(name)
67 lines = reversion(name)
68 tmp_name = name + "_tmp"
69 mv name, tmp_name
70 begin
71 File.open(name, "w") { |f| f.write lines }
72 rescue
73 mv tmp_name, name
74 ensure
75 rm tmp_name
76 end
77 end
78
79
80
81
82 task :extconf do
83 Dir.chdir(Dist_Directory) { reversion_file "ext/RMagick/extconf.rb" }
84 end
85
86
87
88
89 task :gemspec do
90 Dir.chdir(Dist_Directory) { reversion_file "rmagick.gemspec" }
91 end
92
93
94
95
96 task "README.bc" do
97 Dir.chdir Dist_Directory do
98 reversion_file "README.txt"
99 body = File.readlines "README.txt"
100 body = BlueCloth.new(body.join).to_html + "\n"
101 File.open("README.bc", "w") { |f| f.write body }
102 end
103 end
104
105
106
107
108 task README => "README.bc" do
109 puts "writing #{README}"
110 Dir.chdir Dist_Directory do
111 File.open(README, "w") do |html|
112 html.write <<END_HTML_HEAD
113 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
114 <html>
115 <head>
116 <title>RMagick #{RMagick_Version2} README</title>
117 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
118 <meta name="GENERATOR" content="BlueCloth">
119 </head>
120 <body>
121 END_HTML_HEAD
122 html.write File.readlines("README.bc")
123 html.write <<END_HTML_TAIL
124 </body>
125 </html>
126 END_HTML_TAIL
127 end
128 end
129 end
130
131
132
133
134 task :doc do
135 Dir.chdir(File.join(Dist_Directory, "doc")) do
136 FileList["*.html"].each { |d| reversion_file(d) }
137 end
138 end
139
140
141
142
143 # Remove files we don't want in the tarball.
144 # Ensure files are not executable. (ref: bug #10080)
145 task :fix_files do
146 Dir.chdir Dist_Directory do
147 rm_rf "test", :verbose => true
148 rm "lib/rvg/to_c.rb", :verbose => true
149 rm "README.bc", :verbose => true
150 chmod 0644, FileList["doc/*.html", "doc/ex/*.rb", "doc/ex/images/*", "examples/*.rb"]
151 end
152 end
153
154
155
156
157 task :manifest do
158 now = Time.new
159 now = now.strftime("%H:%M:%S %m/%d/%y")
160 puts "generating #{MANIFEST}"
161
162 Dir.chdir Dist_Directory do
163 File.open(MANIFEST, "w") do |f|
164 f.puts "MANIFEST for #{Release} - #{now}\n\n"
165 Find.find('.') do |name|
166 next if File.directory? name
167 f.puts name[2..-1] # remove leading "./"
168 end
169 end
170 end
171 end
172
173
174
175
176 task :export do
177 sh "cvs -d#{CVSSERVER} export -r #{CVS_Tag} -d #{Dist_Directory} RMagick"
178 end
179
180
181
182
183 task :collateral => ["README.html", :gemspec, :extconf, :doc]
184
7ac054f Polish
rmagick authored
185 GEM = Dist_Directory.downcase + ".gem"
186
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
187 task :default => [:export, :collateral, :fix_files, :manifest] do
188 sh "tar cvfz #{Release}.tar.gz #{Dist_Directory}"
189 sh "tar cvfj #{Release}.tar.bz2 #{Dist_Directory}"
190 Dir.chdir(Dist_Directory) do
191 sh "gem build rmagick.gemspec"
192 mv GEM, "../", :verbose => true
193 end
194 end
195
196
197
198
199 task :clean do
200 rm_rf Dist_Directory, :verbose => true
201 rm_rf Release+".tar.gz", :verbose => true
202 rm_rf Release+".tar.bz2", :verbose => true
203 rm_rf GEM, :verbose => true
204 end
205
Something went wrong with that request. Please try again.