Commit 1c47c9bf880c358f7cb3d7ed6df5ccb2ca26641f
1 parent
3869e431
Exists in
master
and in
28 other branches
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,7 +81,7 @@ EOF | ||
81 | if !pendencies_on_authors[:ok] | 81 | if !pendencies_on_authors[:ok] |
82 | puts "\nThere are changes in the AUTHORS file:" | 82 | puts "\nThere are changes in the AUTHORS file:" |
83 | sh 'git diff AUTHORS' | 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 | sh 'git add AUTHORS' | 85 | sh 'git add AUTHORS' |
86 | sh 'git commit -m "Updating authors file"' | 86 | sh 'git commit -m "Updating authors file"' |
87 | else | 87 | else |
@@ -95,16 +95,19 @@ EOF | @@ -95,16 +95,19 @@ EOF | ||
95 | end | 95 | end |
96 | end | 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 | end | 103 | end |
102 | 104 | ||
103 | def confirm(message, default=true) | 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 | choice = nil | 108 | choice = nil |
106 | while choice.nil? | 109 | while choice.nil? |
107 | - answer = ask(message + choice_message) | 110 | + answer = ask(message, default_value, default_message, '?') |
108 | if answer.blank? | 111 | if answer.blank? |
109 | choice = default | 112 | choice = default |
110 | elsif ['y', 'yes'].include?(answer.downcase) | 113 | elsif ['y', 'yes'].include?(answer.downcase) |
@@ -122,10 +125,10 @@ EOF | @@ -122,10 +125,10 @@ EOF | ||
122 | release_kind = args[:release_kind] || 'stable' | 125 | release_kind = args[:release_kind] || 'stable' |
123 | 126 | ||
124 | if release_kind == 'test' | 127 | if release_kind == 'test' |
125 | - version_question = "Release candidate of which version: " | 128 | + version_question = "Release candidate of which version" |
126 | distribution = 'squeeze-test' | 129 | distribution = 'squeeze-test' |
127 | else | 130 | else |
128 | - version_question = "Version that is being released: " | 131 | + version_question = "Version that is being released" |
129 | distribution = 'unstable' | 132 | distribution = 'unstable' |
130 | end | 133 | end |
131 | 134 | ||
@@ -135,7 +138,7 @@ EOF | @@ -135,7 +138,7 @@ EOF | ||
135 | timestamp = Time.now.strftime('%Y%m%d%H%M%S') | 138 | timestamp = Time.now.strftime('%Y%m%d%H%M%S') |
136 | version_name += "~rc#{timestamp}" | 139 | version_name += "~rc#{timestamp}" |
137 | end | 140 | end |
138 | - release_message = ask("Release message: ") | 141 | + release_message = ask("Release message") |
139 | 142 | ||
140 | sh 'git checkout debian/changelog lib/noosfero.rb' | 143 | sh 'git checkout debian/changelog lib/noosfero.rb' |
141 | sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb" | 144 | sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb" |
@@ -158,27 +161,6 @@ EOF | @@ -158,27 +161,6 @@ EOF | ||
158 | sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}" | 161 | sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}" |
159 | end | 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 | desc 'sets the new version on apropriate files' | 164 | desc 'sets the new version on apropriate files' |
183 | task :set_version, :release_kind do |t, args| | 165 | task :set_version, :release_kind do |t, args| |
184 | next if File.exist?("tmp/pending-release") | 166 | next if File.exist?("tmp/pending-release") |
@@ -198,7 +180,7 @@ EOF | @@ -198,7 +180,7 @@ EOF | ||
198 | timestamp = Time.now.strftime('%Y%m%d%H%M%S') | 180 | timestamp = Time.now.strftime('%Y%m%d%H%M%S') |
199 | version_name += "~rc#{timestamp}" | 181 | version_name += "~rc#{timestamp}" |
200 | end | 182 | end |
201 | - release_message = ask("Release message: ") | 183 | + release_message = ask("Release message") |
202 | 184 | ||
203 | sh 'git checkout debian/changelog lib/noosfero.rb' | 185 | sh 'git checkout debian/changelog lib/noosfero.rb' |
204 | sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb" | 186 | sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb" |
@@ -226,20 +208,35 @@ EOF | @@ -226,20 +208,35 @@ EOF | ||
226 | release_kind = args[:release_kind] || 'stable' | 208 | release_kind = args[:release_kind] || 'stable' |
227 | 209 | ||
228 | Rake::Task['noosfero:set_version'].invoke(release_kind) | 210 | Rake::Task['noosfero:set_version'].invoke(release_kind) |
211 | + puts "==> Checking tags..." | ||
229 | Rake::Task['noosfero:check_tag'].invoke | 212 | Rake::Task['noosfero:check_tag'].invoke |
213 | + puts "==> Checking debian package version..." | ||
230 | Rake::Task['noosfero:check_debian_package'].invoke | 214 | Rake::Task['noosfero:check_debian_package'].invoke |
215 | + puts "==> Checking translations..." | ||
231 | Rake::Task['noosfero:error-pages:translate'].invoke | 216 | Rake::Task['noosfero:error-pages:translate'].invoke |
217 | + puts "==> Updating authors..." | ||
232 | Rake::Task['noosfero:authors'].invoke | 218 | Rake::Task['noosfero:authors'].invoke |
219 | + puts "==> Checking repository..." | ||
233 | Rake::Task['noosfero:check_repo'].invoke | 220 | Rake::Task['noosfero:check_repo'].invoke |
221 | + puts "==> Preparing debian packages..." | ||
234 | Rake::Task['noosfero:debian_packages'].invoke | 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 | sh "git tag #{version.gsub('~','-')}" | 228 | sh "git tag #{version.gsub('~','-')}" |
238 | push_tags = confirm('Push new version tag') | 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 | sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present? | 236 | sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present? |
241 | puts "I: please upload the tarball and Debian packages to the website!" | 237 | puts "I: please upload the tarball and Debian packages to the website!" |
242 | puts "I: please push the tag for version #{version} that was just created!" if !push_tags | 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 | end | 240 | end |
244 | 241 | ||
245 | desc 'Build Debian packages' | 242 | desc 'Build Debian packages' |