Skip to content
Newer
Older
100644 218 lines (181 sloc) 7.85 KB
520d7c7 Separating release process into staging and releasing
Assaf Arkin authored Apr 25, 2008
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with this
3 # work for additional information regarding copyright ownership. The ASF
4 # licenses this file to you under the Apache License, Version 2.0 (the
5 # "License"); you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations under
14 # the License.
15
6022991 Small fixes required for the release process
Antoine Toulme authored Nov 18, 2011
16 require 'rubyforge'
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
17 require 'digest/md5'
18 require 'digest/sha1'
520d7c7 Separating release process into staging and releasing
Assaf Arkin authored Apr 25, 2008
19
6c98af5 support for the gpg cmd in case gpg is installed, not gpg2
Antoine Toulme authored Apr 1, 2010
20 gpg_cmd = 'gpg2'
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
21
538f7b2 Fixed rake stage for quicker error reporting.
Assaf Arkin authored Mar 27, 2009
22 task :prepare do |task, args|
12d6be8 fix a few problems with the stage script
Antoine Toulme authored Nov 18, 2011
23 gpg_arg = args.gpg || ENV['gpg']
24
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
25 # Make sure we're doing a release from checked code.
26 lambda do
27 puts "Checking there are no local changes ... "
28 svn = `svn status`
7f21838 put back the SVN check when staging for releases
Antoine Toulme authored Nov 18, 2011
29 fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
abc1874 Upgrade to version 1.4.6 in preparation for release
Alex Boisvert authored Jun 21, 2011
30 git = `git status -s`
31 fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^ M/] && ENV["IGNORE_GIT"].nil?
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
32 puts "[X] There are no local changes, everything is in source control"
33 end.call
34
35 # Make sure we have a valid CHANGELOG entry for this release.
36 lambda do
37 puts "Checking that CHANGELOG indicates most recent version and today's date ... "
38 expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
39 header = File.readlines('CHANGELOG').first.chomp
40 fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
41 puts "[x] CHANGELOG indicates most recent version and today's date"
42 end.call
43
538f7b2 Fixed rake stage for quicker error reporting.
Assaf Arkin authored Mar 27, 2009
44 # Need GPG to sign the packages.
45 lambda do
12d6be8 fix a few problems with the stage script
Antoine Toulme authored Nov 18, 2011
46 gpg_arg or fail "Please run with gpg=<argument for gpg --local-user>"
47 gpg_ok = `gpg2 --list-keys #{gpg_arg}` rescue nil
6c98af5 support for the gpg cmd in case gpg is installed, not gpg2
Antoine Toulme authored Apr 1, 2010
48 if !$?.success?
12d6be8 fix a few problems with the stage script
Antoine Toulme authored Nov 18, 2011
49 gpg_ok = `gpg --list-keys #{gpg_arg}`
6c98af5 support for the gpg cmd in case gpg is installed, not gpg2
Antoine Toulme authored Apr 1, 2010
50 gpg_cmd = 'gpg'
51 end
12d6be8 fix a few problems with the stage script
Antoine Toulme authored Nov 18, 2011
52 fail "No GPG user #{gpg_arg}" if gpg_ok.empty?
538f7b2 Fixed rake stage for quicker error reporting.
Assaf Arkin authored Mar 27, 2009
53 end.call
54
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
55 task(:license).invoke
56
57 # Need JRuby, Scala and Groovy installed to run all the specs.
58 lambda do
59 puts "Checking that we have JRuby, Scala and Groovy available ... "
60 sh 'jruby --version'
6022991 Small fixes required for the release process
Antoine Toulme authored Nov 18, 2011
61 `scala -version`
62 $?.exitstatus == 1 or fail "Scala is not installed"
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
63 sh 'groovy -version'
64 puts "[X] We have JRuby, Scala and Groovy"
65 end.call
66
9bafda0 Add check for 'prince' early in the stage process
Alex Boisvert authored Oct 4, 2009
67 # Need Prince to generate PDF
68 lambda do
69 puts "Checking that we have prince available ... "
70 sh 'prince --version'
71 puts "[X] We have prince available"
72 end.call
73
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
74 # Need RubyForge to upload new release files.
75 lambda do
76 puts "[!] Make sure you have admin privileges to make a release on RubyForge"
77 rubyforge = RubyForge.new.configure
992be9f Remove trailing whitespace on all Ruby files
Alex Boisvert authored Mar 5, 2010
78 rubyforge.login
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
79 rubyforge.scrape_project(spec.name)
80 end.call
81
82 # We will be speccing in one platform, so also spec the other one.
83 task(RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby').invoke # Test the *other* platform
520d7c7 Separating release process into staging and releasing
Assaf Arkin authored Apr 25, 2008
84 end
85
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
86
fac1b84 setup task no longer exists
Alex Boisvert authored Oct 7, 2011
87 task :stage=>[:clobber, :prepare] do |task, args|
6022991 Small fixes required for the release process
Antoine Toulme authored Nov 18, 2011
88 gpg_arg = args.gpg || ENV['gpg']
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
89 mkpath '_staged'
90
91 # Start by figuring out what has changed.
92 lambda do
93 puts "Looking for changes between this release and previous one ..."
94 pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
95 changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
96 current = changes[spec.version.to_s]
97 fail "No changeset found for version #{spec.version}" unless current
98 File.open '_staged/CHANGES', 'w' do |file|
99 file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
100 file.write current
101 end
102 puts "[X] Listed most recent changed in _staged/CHANGES"
103 end.call
104
105 # Create the packages (gem, tarball) and sign them. This requires user
106 # intervention so the earlier we do it the better.
107 lambda do
108 puts "Creating and signing release packages ..."
109 task(:package).invoke
110 mkpath '_staged/dist'
111 FileList['pkg/*.{gem,zip,tgz}'].each do |source|
992be9f Remove trailing whitespace on all Ruby files
Alex Boisvert authored Mar 5, 2010
112 pkg = source.pathmap('_staged/dist/%n%x')
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
113 cp source, pkg
114 bytes = File.open(pkg, 'rb') { |file| file.read }
115 File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
116 File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
12d6be8 fix a few problems with the stage script
Antoine Toulme authored Nov 18, 2011
117 sh gpg_cmd, '--local-user', gpg_arg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
118 end
d88477d Update download links to point to Apache mirrors
Alex Boisvert authored Dec 8, 2009
119 cp 'etc/KEYS', '_staged/dist'
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
120 puts "[X] Created and signed release packages in _staged/dist"
121 end.call
122
123 # The download page should link to the new binaries/sources, and we
124 # want to do that before generating the site/documentation.
125 lambda do
126 puts "Updating download page with links to release packages ... "
d88477d Update download links to point to Apache mirrors
Alex Boisvert authored Dec 8, 2009
127 mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
128 official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
bb43cb2 Fixed bug in rake stage not creating download links.
Assaf Arkin authored Apr 7, 2009
129 rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
130 name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
d88477d Update download links to point to Apache mirrors
Alex Boisvert authored Dec 8, 2009
131 %{| "#{name}":#{mirror}/#{name} | "#{md5}":#{official}/#{name}.md5 | "Sig":#{official}/#{name}.asc |}
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
132 }
133 textile = <<-TEXTILE
134 h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
135
136 |_. Package |_. MD5 Checksum |_. PGP |
137 #{rows.join("\n")}
138
d88477d Update download links to point to Apache mirrors
Alex Boisvert authored Dec 8, 2009
139 p>. ("Release signing keys":#{official}/KEYS)
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
140 TEXTILE
141 file_name = 'doc/download.textile'
142 print "Adding download links to #{file_name} ... "
143 modified = File.read(file_name).sub(/^h2\(#dist\).*$/) { |header| "#{header}\n\n#{textile}" }
144 File.open file_name, 'w' do |file|
145 file.write modified
146 end
147 puts "[X] Updated #{file_name}"
148 end.call
149
150
151 # Now we can create the Web site, this includes running specs, coverage report, etc.
152 # This will take a while, so we want to do it as last step before upload.
153 lambda do
154 puts "Creating new Web site"
155 task(:site).invoke
156 cp_r '_site', '_staged/site'
157 puts "[X] Created new Web site in _staged/site"
158 end.call
159
160
161 # Move everything over to people.apache.org so we can vote on it.
162 lambda do
163 url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
164 puts "Uploading _staged directory to #{url} ..."
165 sh 'rsync', '--progress', '--recursive', '_staged/', url
166 puts "[X] Uploaded _staged directory to #{url}"
167 end.call
992be9f Remove trailing whitespace on all Ruby files
Alex Boisvert authored Mar 5, 2010
168
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
169
170 # Prepare a release vote email. In the distant future this will also send the
171 # email for you and vote on it.
172 lambda do
173 # Need to know who you are on Apache, local user may be different (see .ssh/config).
174 whoami = `ssh people.apache.org whoami`.strip
175 base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
176 # Need changes for this release only.
177 changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
178 changes = changelog[0][2]
179 previous_version = changelog[1][1]
180
181 email = <<-EMAIL
182 To: dev@buildr.apache.org
183 Subject: [VOTE] Buildr #{spec.version} release
184
185 We're voting on the source distributions available here:
186 #{base_url}/dist/
187
188 Specifically:
189 #{base_url}/dist/buildr-#{spec.version}.tgz
190 #{base_url}/dist/buildr-#{spec.version}.zip
191
192 The documentation generated for this release is available here:
193 #{base_url}/site/
194 #{base_url}/site/buildr.pdf
195
196 The official specification against which this release was tested:
197 #{base_url}/site/specs.html
198
199 Test coverage report:
200 #{base_url}/site/coverage/index.html
201
202
203 The following changes were made since #{previous_version}:
204
1349393 Buildr release process: better Rubyforge announcement on new release,…
Assaf Arkin authored Mar 19, 2009
205 #{changes.gsub(/^/, ' ')}
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
206 EMAIL
207 File.open 'vote-email.txt', 'w' do |file|
208 file.write email
209 end
210 puts "[X] Created release vote email template in 'vote-email.txt'"
211 puts email
212 end.call
213
520d7c7 Separating release process into staging and releasing
Assaf Arkin authored Apr 25, 2008
214 end
215
aab93ad New and improved rakelib.
Assaf Arkin authored Mar 13, 2009
216
217 task(:clobber) { rm_rf '_staged' }
Something went wrong with that request. Please try again.