Commit 1c47c9bf880c358f7cb3d7ed6df5ccb2ca26641f

Authored by Rodrigo Souto
1 parent 3869e431

Improving release script

Showing 1 changed file with 30 additions and 33 deletions   Show diff stats
lib/tasks/release.rake
... ... @@ -81,7 +81,7 @@ EOF
81 81 if !pendencies_on_authors[:ok]
82 82 puts "\nThere are changes in the AUTHORS file:"
83 83 sh 'git diff AUTHORS'
84   - if confirm('Do you want to commit these changes?')
  84 + if confirm('Do you want to commit these changes')
85 85 sh 'git add AUTHORS'
86 86 sh 'git commit -m "Updating authors file"'
87 87 else
... ... @@ -95,16 +95,19 @@ EOF
95 95 end
96 96 end
97 97  
98   - def ask(message)
99   - print message
100   - STDIN.gets.chomp
  98 + def ask(message, default = nil, default_message = nil, symbol = ':')
  99 + default_choice = default ? " [#{default_message || default}]#{symbol} " : "#{symbol} "
  100 + print message + default_choice
  101 + answer = STDIN.gets.chomp
  102 + answer.blank? && default.present? ? default : answer
101 103 end
102 104  
103 105 def confirm(message, default=true)
104   - choice_message = default ? ' [Y/n]? ' : ' [y/N]? '
  106 + default_message = default ? 'Y/n' : 'y/N'
  107 + default_value = default ? 'y' : 'n'
105 108 choice = nil
106 109 while choice.nil?
107   - answer = ask(message + choice_message)
  110 + answer = ask(message, default_value, default_message, '?')
108 111 if answer.blank?
109 112 choice = default
110 113 elsif ['y', 'yes'].include?(answer.downcase)
... ... @@ -122,10 +125,10 @@ EOF
122 125 release_kind = args[:release_kind] || 'stable'
123 126  
124 127 if release_kind == 'test'
125   - version_question = "Release candidate of which version: "
  128 + version_question = "Release candidate of which version"
126 129 distribution = 'squeeze-test'
127 130 else
128   - version_question = "Version that is being released: "
  131 + version_question = "Version that is being released"
129 132 distribution = 'unstable'
130 133 end
131 134  
... ... @@ -135,7 +138,7 @@ EOF
135 138 timestamp = Time.now.strftime('%Y%m%d%H%M%S')
136 139 version_name += "~rc#{timestamp}"
137 140 end
138   - release_message = ask("Release message: ")
  141 + release_message = ask("Release message")
139 142  
140 143 sh 'git checkout debian/changelog lib/noosfero.rb'
141 144 sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb"
... ... @@ -158,27 +161,6 @@ EOF
158 161 sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}"
159 162 end
160 163  
161   - def ask(message)
162   - print message
163   - STDIN.gets.chomp
164   - end
165   -
166   - def confirm(message, default=true)
167   - choice_message = default ? ' [Y/n]? ' : ' [y/N]? '
168   - choice = nil
169   - while choice.nil?
170   - answer = ask(message + choice_message)
171   - if answer.blank?
172   - choice = default
173   - elsif ['y', 'yes'].include?(answer.downcase)
174   - choice = true
175   - elsif ['n', 'no'].include?(answer.downcase)
176   - choice = false
177   - end
178   - end
179   - choice
180   - end
181   -
182 164 desc 'sets the new version on apropriate files'
183 165 task :set_version, :release_kind do |t, args|
184 166 next if File.exist?("tmp/pending-release")
... ... @@ -198,7 +180,7 @@ EOF
198 180 timestamp = Time.now.strftime('%Y%m%d%H%M%S')
199 181 version_name += "~rc#{timestamp}"
200 182 end
201   - release_message = ask("Release message: ")
  183 + release_message = ask("Release message")
202 184  
203 185 sh 'git checkout debian/changelog lib/noosfero.rb'
204 186 sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb"
... ... @@ -226,20 +208,35 @@ EOF
226 208 release_kind = args[:release_kind] || 'stable'
227 209  
228 210 Rake::Task['noosfero:set_version'].invoke(release_kind)
  211 + puts "==> Checking tags..."
229 212 Rake::Task['noosfero:check_tag'].invoke
  213 + puts "==> Checking debian package version..."
230 214 Rake::Task['noosfero:check_debian_package'].invoke
  215 + puts "==> Checking translations..."
231 216 Rake::Task['noosfero:error-pages:translate'].invoke
  217 + puts "==> Updating authors..."
232 218 Rake::Task['noosfero:authors'].invoke
  219 + puts "==> Checking repository..."
233 220 Rake::Task['noosfero:check_repo'].invoke
  221 + puts "==> Preparing debian packages..."
234 222 Rake::Task['noosfero:debian_packages'].invoke
235   - Rake::Task['noosfero:upload_packages'].invoke(release_kind)
  223 + if confirm('Do you want to upload the packages')
  224 + puts "==> Uploading debian packages..."
  225 + Rake::Task['noosfero:upload_packages'].invoke(release_kind)
  226 + end
236 227  
237 228 sh "git tag #{version.gsub('~','-')}"
238 229 push_tags = confirm('Push new version tag')
239   - sh 'git push --tags' if push_tags
  230 + if push_tags
  231 + repository = ask('Repository name', 'origin')
  232 + puts "==> Uploading tags..."
  233 + sh "git push #{repository} #{version.gsub('~','-')}"
  234 + end
  235 +
240 236 sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present?
241 237 puts "I: please upload the tarball and Debian packages to the website!"
242 238 puts "I: please push the tag for version #{version} that was just created!" if !push_tags
  239 + puts "I: notify the community about this sparkling new version!"
243 240 end
244 241  
245 242 desc 'Build Debian packages'
... ...