Commit 5ec0e4457388a4e772b441c23db9f3f402ff07b0

Authored by Antonio Terceiro
1 parent 4885ad01

update release rake tasks

Showing 1 changed file with 68 additions and 70 deletions   Show diff stats
lib/tasks/release.rake
1 1 # encoding: UTF-8
2 2  
  3 +require 'noosfero/version'
  4 +$version = Noosfero::VERSION
  5 +
3 6 namespace :noosfero do
4 7  
5 8 def pendencies_on_authors
6   - sh "git status | grep 'AUTHORS' > /dev/null" do |ok, res|
  9 + sh "git status | grep 'AUTHORS.md' > /dev/null" do |ok, res|
7 10 return {:ok => !ok, :res => res}
8 11 end
9 12 end
10 13  
11 14 def pendencies_on_repo
12   - sh "git status | grep 'nothing.*commit' > /dev/null" do |ok, res|
  15 + sh "git status | grep 'nothing.*commit' > /dev/null" do |ok, res|
13 16 return {:ok => ok, :res => res}
14 17 end
15 18 end
16 19  
17 20 def pendencies_on_public_errors
18   - sh "git status | grep -e '500.html' -e '503.html' > /dev/null" do |ok, res|
  21 + sh "git status | grep -e '500.html' -e '503.html' > /dev/null" do |ok, res|
19 22 return {:ok => !ok, :res => res}
20 23 end
21 24 end
... ... @@ -40,32 +43,16 @@ namespace :noosfero do
40 43 end
41 44 end
42 45  
43   - def version
44   - require 'noosfero'
45   - Noosfero::VERSION
46   - end
47   -
48 46 desc 'checks if there is already a tag for the current version'
49 47 task :check_tag do
50   - sh "git tag | grep '^#{version}$' >/dev/null" do |ok, res|
  48 + sh "git tag | grep '^#{$version}$' >/dev/null" do |ok, res|
51 49 if ok
52   - raise "******** There is already a tag for version #{version}, cannot continue"
  50 + raise "******** There is already a tag for version #{$version}, cannot continue"
53 51 end
54 52 end
55   - puts "Not found tag for version #{version}, we can go on."
  53 + puts "Not found tag for version #{$version}, we can go on."
56 54 end
57 55  
58   - desc 'checks the version of the Debian package'
59   - task :check_debian_package do
60   - debian_version = `dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2`.strip
61   - unless debian_version =~ /^#{version}/
62   - puts "Version mismatch: Debian version = #{debian_version}, Noosfero upstream version = #{version}"
63   - puts "Run `dch -v #{version}` to add a new changelog entry that upgrades the Debian version"
64   - raise "Version mismatch between noosfero version and debian package version"
65   - end
66   - end
67   -
68   -
69 56 AUTHORS_HEADER = <<EOF
70 57 If you are not listed here, but should be, please write to the noosfero mailing
71 58 list: http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
... ... @@ -91,15 +78,15 @@ Arts
91 78 Nara Oliveira <narananet@gmail.com>
92 79 EOF
93 80  
94   - desc 'updates the AUTHORS file'
  81 + desc 'updates the authors file'
95 82 task :authors do
96 83 begin
97   - File.open("AUTHORS", 'w') do |output|
  84 + File.open("AUTHORS.md", 'w') do |output|
98 85 output.puts AUTHORS_HEADER
99 86 output.puts `git log --pretty=format:'%aN <%aE>' | sort | uniq`
100 87 output.puts AUTHORS_FOOTER
101 88 end
102   - commit_changes(['AUTHORS'], 'Updating AUTHORS file') if !pendencies_on_authors[:ok]
  89 + commit_changes(['AUTHORS.md'], 'Updating authors file') if !pendencies_on_authors[:ok]
103 90 rescue Exception => e
104 91 rm_f 'AUTHORS'
105 92 raise e
... ... @@ -131,72 +118,87 @@ EOF
131 118 end
132 119  
133 120 desc "uploads the packages to the repository"
134   - task :upload_packages, :release_kind do |t, args|
135   - release_kind = args[:release_kind] || 'stable'
136   - sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}"
  121 + task :upload_packages, :target do |t, args|
  122 + target = args[:target] || 'stable'
  123 + sh "dput --unchecked noosfero-#{target} #{Dir['pkg/*.changes'].first}"
137 124 end
138 125  
139 126 desc 'sets the new version on apropriate files'
140   - task :set_version, :release_kind do |t, args|
  127 + task :set_version, :target do |t, args|
141 128 next if File.exist?("tmp/pending-release")
142   - release_kind = args[:release_kind] || 'stable'
143   -
144   - if release_kind =~ /test/
145   - version_question = "Release candidate of which version: "
146   - if release_kind == 'squeeze-test'
147   - distribution = 'squeeze-test'
148   - elsif release_kind == 'wheezy-test'
149   - distribution = 'wheezy-test'
  129 + target = args[:target]
  130 +
  131 + new_version = $version.dup
  132 +
  133 + if target =~ /-test$/
  134 + if new_version =~ /~rc\d\+/
  135 + new_version.sub!(/\~rc([0-9]+)/) { "~rc#{$1.to_i + 1}" }
  136 + else
  137 + new_version += '~rc1'
150 138 end
151 139 else
152   - version_question = "Version that is being released: "
153   - distribution = 'unstable'
  140 + new_version.sub!(/~rc[0-9]+/, '')
154 141 end
155 142  
156   - version_name = new_version = ask(version_question)
157   -
158   - if release_kind =~ /test/
159   - timestamp = Time.now.strftime('%Y%m%d%H%M%S')
160   - version_name += "~rc#{timestamp}"
161   - end
  143 + puts "Current version: #{$version}"
  144 + ask("Version to release" % new_version, new_version)
162 145 release_message = ask("Release message")
163 146  
164   - sh 'git checkout debian/changelog lib/noosfero.rb'
165   - sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb"
166   - sh "dch --newversion #{version_name} --distribution #{distribution} --force-distribution '#{release_message}'"
  147 + sh 'git checkout debian/changelog lib/noosfero/version.rb'
  148 + sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{new_version}'/\" lib/noosfero/version.rb"
  149 + sh "dch --newversion #{new_version} --distribution #{target} --force-distribution '#{release_message}'"
167 150  
168   - sh 'git diff debian/changelog lib/noosfero.rb'
169   - if confirm("Commit version bump to #{version_name} on #{distribution} distribution")
170   - sh 'git add debian/changelog lib/noosfero.rb'
171   - sh "git commit -m 'Bumping version #{version_name}'"
  151 + sh 'git diff debian/changelog lib/noosfero/version.rb'
  152 + if confirm("Commit version bump to #{new_version} on #{target} distribution")
  153 + sh 'git add debian/changelog lib/noosfero/version.rb'
  154 + sh "git commit -m 'Bumping version #{new_version}'"
172 155 sh "touch tmp/pending-release"
173 156 else
174   - sh 'git checkout debian/changelog lib/noosfero.rb'
  157 + sh 'git checkout debian/changelog lib/noosfero/version.rb'
175 158 abort 'Version update not confirmed. Reverting changes and exiting...'
176 159 end
  160 +
  161 + $version = new_version
  162 + end
  163 +
  164 + task :check_release_deps do
  165 + missing = false
  166 + {
  167 + dput: :dput,
  168 + dch: :devscripts,
  169 + }.each do |program, package|
  170 + if ! system("which #{program} >/dev/null 2>&1")
  171 + puts "Program #{program} missing, install the package #{package}"
  172 + missing = true
  173 + end
  174 + end
  175 + abort if missing
177 176 end
178 177  
179 178 desc 'prepares a release tarball'
180   - task :release, :release_kind do |t, args|
181   - release_kind = args[:release_kind] || 'stable'
  179 + task :release, :target do |t, args|
  180 + target = args[:target]
  181 + if ! target
  182 + abort "Usage: rake noosfero:release[TARGET]"
  183 + end
  184 +
  185 + puts "==> Checking required packages"
  186 + Rake::Task['noosfero:check_release_deps'].invoke
182 187  
183 188 puts "==> Updating authors..."
184 189 Rake::Task['noosfero:authors'].invoke
185 190  
186   - Rake::Task['noosfero:set_version'].invoke(release_kind)
187   -
188   - puts "==> Checking tags..."
189   - Rake::Task['noosfero:check_tag'].invoke
190   -
191   - puts "==> Checking debian package version..."
192   - Rake::Task['noosfero:check_debian_package'].invoke
193   -
194 191 puts "==> Checking translations..."
195 192 Rake::Task['noosfero:error-pages:translate'].invoke
196 193 if !pendencies_on_public_errors[:ok]
197 194 commit_changes(['public/500.html', 'public/503.html'], 'Updating public error pages')
198 195 end
199 196  
  197 + Rake::Task['noosfero:set_version'].invoke(target)
  198 +
  199 + puts "==> Checking tags..."
  200 + Rake::Task['noosfero:check_tag'].invoke
  201 +
200 202 puts "==> Checking repository..."
201 203 Rake::Task['noosfero:check_repo'].invoke
202 204  
... ... @@ -204,22 +206,18 @@ EOF
204 206 Rake::Task['noosfero:debian_packages'].invoke
205 207 if confirm('Do you want to upload the packages')
206 208 puts "==> Uploading debian packages..."
207   - Rake::Task['noosfero:upload_packages'].invoke(release_kind)
  209 + Rake::Task['noosfero:upload_packages'].invoke(target)
208 210 end
209 211  
210   - sh "git tag #{version.gsub('~','-')}"
  212 + sh "git tag #{$version.gsub('~','-')}"
211 213 push_tags = confirm('Push new version tag')
212 214 if push_tags
213 215 repository = ask('Repository name', 'origin')
214 216 puts "==> Uploading tags..."
215   - sh "git push #{repository} #{version.gsub('~','-')}"
  217 + sh "git push #{repository} #{$version.gsub('~','-')}"
216 218 end
217 219  
218 220 sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present?
219   -
220   - puts "I: please upload the tarball and Debian packages to the website!"
221   - puts "I: please push the tag for version #{version} that was just created!" if !push_tags
222   - puts "I: notify the community about this sparkling new version!"
223 221 end
224 222  
225 223 desc 'Build Debian packages'
... ...