Commit 8195b99361dd62e2afbfe0d9387c64b3edb4ae3a

Authored by Rodrigo Souto
1 parent a2179a73

Upgrading release script

Extending the release script to update the version being released in the
appropriate files, commit eventual changes on the authors file and also
upload the package to the repository configured via dput.cf (located on
the home of the user).
Showing 1 changed file with 93 additions and 3 deletions   Show diff stats
lib/tasks/release.rake
... ... @@ -68,17 +68,107 @@ EOF
68 68 output.puts `git log --pretty=format:'%aN <%aE>' | sort | uniq`
69 69 output.puts AUTHORS_FOOTER
70 70 end
  71 + sh "git status | grep 'AUTHORS' > /dev/null" do |ok, res|
  72 + if ok
  73 + puts "\nThere are changes in the AUTHORS file:"
  74 + sh 'git diff AUTHORS'
  75 + if confirm('Do you want to commit these changes?')
  76 + sh 'git add AUTHORS'
  77 + sh 'git commit -m "Updating authors file"'
  78 + else
  79 + sh 'git checkout AUTHORS'
  80 + abort 'There are new authors to be commited. Reverting changes and exiting...'
  81 + end
  82 + end
  83 + end
71 84 rescue Exception => e
72 85 rm_f 'AUTHORS'
73 86 raise e
74 87 end
75 88 end
76 89  
  90 + def ask(message)
  91 + print message
  92 + STDIN.gets.chomp
  93 + end
  94 +
  95 + def confirm(message, default=true)
  96 + choice_message = default ? ' [Y/n]? ' : ' [y/N]? '
  97 + choice = nil
  98 + while choice.nil?
  99 + answer = ask(message + choice_message)
  100 + if answer.blank?
  101 + choice = default
  102 + elsif ['y', 'yes'].include?(answer.downcase)
  103 + choice = true
  104 + elsif ['n', 'no'].include?(answer.downcase)
  105 + choice = false
  106 + end
  107 + end
  108 + choice
  109 + end
  110 +
  111 + desc 'sets the new version on apropriate files'
  112 + task :set_version, :release_kind do |t, args|
  113 + next if File.exist?("tmp/pending-release")
  114 + release_kind = args[:release_kind] || 'stable'
  115 +
  116 + if release_kind == 'test'
  117 + version_question = "Release candidate of which version: "
  118 + distribution = 'squeeze-test'
  119 + else
  120 + version_question = "Version that is being released: "
  121 + distribution = 'unstable'
  122 + end
  123 +
  124 + version_name = new_version = ask(version_question)
  125 +
  126 + if release_kind == 'test'
  127 + timestamp = Time.now.strftime('%Y%m%d%H%M%S')
  128 + version_name += "~rc#{timestamp}"
  129 + end
  130 + release_message = ask("Release message: ")
  131 +
  132 + sh 'git checkout debian/changelog lib/noosfero.rb'
  133 + sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb"
  134 + sh "dch --newversion #{version_name} --distribution #{distribution} --force-distribution '#{release_message}'"
  135 +
  136 + sh 'git diff debian/changelog lib/noosfero.rb'
  137 + if confirm("Commit version bump to #{version_name} on #{distribution} distribution")
  138 + sh 'git add debian/changelog lib/noosfero.rb'
  139 + sh "git commit -m 'Bumping version #{version_name}'"
  140 + sh "touch tmp/pending-release"
  141 + else
  142 + sh 'git checkout debian/changelog lib/noosfero.rb'
  143 + abort 'Version update not confirmed. Reverting changes and exiting...'
  144 + end
  145 + end
  146 +
  147 + desc "uploads the packages to the repository"
  148 + task :upload_packages, :release_kind do |t, args|
  149 + release_kind = args[:release_kind] || 'stable'
  150 + sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}"
  151 + end
  152 +
77 153 desc 'prepares a release tarball'
78   - task :release => [ :check_tag, :check_debian_package, 'noosfero:error-pages:translate', :authors, :check_repo, :package, :debian_packages ] do
79   - sh "git tag #{version}"
  154 + task :release, :release_kind do |t, args|
  155 + release_kind = args[:release_kind] || 'stable'
  156 +
  157 + Rake::Task['noosfero:set_version'].invoke(release_kind)
  158 + Rake::Task['noosfero:check_tag'].invoke
  159 + Rake::Task['noosfero:check_debian_package'].invoke
  160 + Rake::Task['noosfero:error-pages:translate'].invoke
  161 + Rake::Task['noosfero:authors'].invoke
  162 + Rake::Task['noosfero:check_repo'].invoke
  163 + Rake::Task['noosfero:debian_packages'].invoke
  164 + Rake::Task['noosfero:upload_packages'].invoke(release_kind)
  165 +
  166 + sh "git tag #{version.gsub('~','-')}"
  167 + push_tags = confirm('Push new version tag')
  168 + sh 'git push --tags' if push_tags
  169 + sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present?
80 170 puts "I: please upload the tarball and Debian packages to the website!"
81   - puts "I: please push the tag for version #{version} that was just created!"
  171 + puts "I: please push the tag for version #{version} that was just created!" if !push_tags
82 172 end
83 173  
84 174 desc 'Build Debian packages'
... ...