Commit 5ec0e4457388a4e772b441c23db9f3f402ff07b0
1 parent
4885ad01
Exists in
master
and in
27 other branches
update release rake tasks
Showing
1 changed file
with
68 additions
and
70 deletions
Show diff stats
lib/tasks/release.rake
| 1 | # encoding: UTF-8 | 1 | # encoding: UTF-8 |
| 2 | 2 | ||
| 3 | +require 'noosfero/version' | ||
| 4 | +$version = Noosfero::VERSION | ||
| 5 | + | ||
| 3 | namespace :noosfero do | 6 | namespace :noosfero do |
| 4 | 7 | ||
| 5 | def pendencies_on_authors | 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 | return {:ok => !ok, :res => res} | 10 | return {:ok => !ok, :res => res} |
| 8 | end | 11 | end |
| 9 | end | 12 | end |
| 10 | 13 | ||
| 11 | def pendencies_on_repo | 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 | return {:ok => ok, :res => res} | 16 | return {:ok => ok, :res => res} |
| 14 | end | 17 | end |
| 15 | end | 18 | end |
| 16 | 19 | ||
| 17 | def pendencies_on_public_errors | 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 | return {:ok => !ok, :res => res} | 22 | return {:ok => !ok, :res => res} |
| 20 | end | 23 | end |
| 21 | end | 24 | end |
| @@ -40,32 +43,16 @@ namespace :noosfero do | @@ -40,32 +43,16 @@ namespace :noosfero do | ||
| 40 | end | 43 | end |
| 41 | end | 44 | end |
| 42 | 45 | ||
| 43 | - def version | ||
| 44 | - require 'noosfero' | ||
| 45 | - Noosfero::VERSION | ||
| 46 | - end | ||
| 47 | - | ||
| 48 | desc 'checks if there is already a tag for the current version' | 46 | desc 'checks if there is already a tag for the current version' |
| 49 | task :check_tag do | 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 | if ok | 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 | end | 51 | end |
| 54 | end | 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 | end | 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 | AUTHORS_HEADER = <<EOF | 56 | AUTHORS_HEADER = <<EOF |
| 70 | If you are not listed here, but should be, please write to the noosfero mailing | 57 | If you are not listed here, but should be, please write to the noosfero mailing |
| 71 | list: http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev | 58 | list: http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev |
| @@ -91,15 +78,15 @@ Arts | @@ -91,15 +78,15 @@ Arts | ||
| 91 | Nara Oliveira <narananet@gmail.com> | 78 | Nara Oliveira <narananet@gmail.com> |
| 92 | EOF | 79 | EOF |
| 93 | 80 | ||
| 94 | - desc 'updates the AUTHORS file' | 81 | + desc 'updates the authors file' |
| 95 | task :authors do | 82 | task :authors do |
| 96 | begin | 83 | begin |
| 97 | - File.open("AUTHORS", 'w') do |output| | 84 | + File.open("AUTHORS.md", 'w') do |output| |
| 98 | output.puts AUTHORS_HEADER | 85 | output.puts AUTHORS_HEADER |
| 99 | output.puts `git log --pretty=format:'%aN <%aE>' | sort | uniq` | 86 | output.puts `git log --pretty=format:'%aN <%aE>' | sort | uniq` |
| 100 | output.puts AUTHORS_FOOTER | 87 | output.puts AUTHORS_FOOTER |
| 101 | end | 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 | rescue Exception => e | 90 | rescue Exception => e |
| 104 | rm_f 'AUTHORS' | 91 | rm_f 'AUTHORS' |
| 105 | raise e | 92 | raise e |
| @@ -131,72 +118,87 @@ EOF | @@ -131,72 +118,87 @@ EOF | ||
| 131 | end | 118 | end |
| 132 | 119 | ||
| 133 | desc "uploads the packages to the repository" | 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 | end | 124 | end |
| 138 | 125 | ||
| 139 | desc 'sets the new version on apropriate files' | 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 | next if File.exist?("tmp/pending-release") | 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 | end | 138 | end |
| 151 | else | 139 | else |
| 152 | - version_question = "Version that is being released: " | ||
| 153 | - distribution = 'unstable' | 140 | + new_version.sub!(/~rc[0-9]+/, '') |
| 154 | end | 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 | release_message = ask("Release message") | 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 | sh "touch tmp/pending-release" | 155 | sh "touch tmp/pending-release" |
| 173 | else | 156 | else |
| 174 | - sh 'git checkout debian/changelog lib/noosfero.rb' | 157 | + sh 'git checkout debian/changelog lib/noosfero/version.rb' |
| 175 | abort 'Version update not confirmed. Reverting changes and exiting...' | 158 | abort 'Version update not confirmed. Reverting changes and exiting...' |
| 176 | end | 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 | end | 176 | end |
| 178 | 177 | ||
| 179 | desc 'prepares a release tarball' | 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 | puts "==> Updating authors..." | 188 | puts "==> Updating authors..." |
| 184 | Rake::Task['noosfero:authors'].invoke | 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 | puts "==> Checking translations..." | 191 | puts "==> Checking translations..." |
| 195 | Rake::Task['noosfero:error-pages:translate'].invoke | 192 | Rake::Task['noosfero:error-pages:translate'].invoke |
| 196 | if !pendencies_on_public_errors[:ok] | 193 | if !pendencies_on_public_errors[:ok] |
| 197 | commit_changes(['public/500.html', 'public/503.html'], 'Updating public error pages') | 194 | commit_changes(['public/500.html', 'public/503.html'], 'Updating public error pages') |
| 198 | end | 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 | puts "==> Checking repository..." | 202 | puts "==> Checking repository..." |
| 201 | Rake::Task['noosfero:check_repo'].invoke | 203 | Rake::Task['noosfero:check_repo'].invoke |
| 202 | 204 | ||
| @@ -204,22 +206,18 @@ EOF | @@ -204,22 +206,18 @@ EOF | ||
| 204 | Rake::Task['noosfero:debian_packages'].invoke | 206 | Rake::Task['noosfero:debian_packages'].invoke |
| 205 | if confirm('Do you want to upload the packages') | 207 | if confirm('Do you want to upload the packages') |
| 206 | puts "==> Uploading debian packages..." | 208 | puts "==> Uploading debian packages..." |
| 207 | - Rake::Task['noosfero:upload_packages'].invoke(release_kind) | 209 | + Rake::Task['noosfero:upload_packages'].invoke(target) |
| 208 | end | 210 | end |
| 209 | 211 | ||
| 210 | - sh "git tag #{version.gsub('~','-')}" | 212 | + sh "git tag #{$version.gsub('~','-')}" |
| 211 | push_tags = confirm('Push new version tag') | 213 | push_tags = confirm('Push new version tag') |
| 212 | if push_tags | 214 | if push_tags |
| 213 | repository = ask('Repository name', 'origin') | 215 | repository = ask('Repository name', 'origin') |
| 214 | puts "==> Uploading tags..." | 216 | puts "==> Uploading tags..." |
| 215 | - sh "git push #{repository} #{version.gsub('~','-')}" | 217 | + sh "git push #{repository} #{$version.gsub('~','-')}" |
| 216 | end | 218 | end |
| 217 | 219 | ||
| 218 | sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present? | 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 | end | 221 | end |
| 224 | 222 | ||
| 225 | desc 'Build Debian packages' | 223 | desc 'Build Debian packages' |