Commit bb1a7ababa1f120ce9b92236403d138795cec38f

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