Commit b96cb5661e2316ba6d98cf67284bc5c3fdd90f0a
1 parent
4e4234b1
Exists in
master
and in
28 other branches
Upgrading release script
Extending the release script to update the version being released in the appropriate files and also upload the package to the repository configured via dput.cf (located on the home of the user).
Showing
1 changed file
with
105 additions
and
7 deletions
Show diff stats
lib/tasks/release.rake
1 | 1 | namespace :noosfero do |
2 | 2 | |
3 | + def pendencies_on_authors | |
4 | + sh "git status | grep 'AUTHORS'" do |ok, res| | |
5 | + return {:ok => ok, :res => res} | |
6 | + end | |
7 | + end | |
8 | + | |
9 | + def pendencies_on_repo | |
10 | + sh "git status | grep 'nothing.*commit'" do |ok, res| | |
11 | + return {:ok => ok, :res => res} | |
12 | + end | |
13 | + end | |
14 | + | |
3 | 15 | desc 'checks if there are uncommitted changes in the repo' |
4 | 16 | task :check_repo do |
5 | - sh "git status | grep 'nothing.*commit'" do |ok, res| | |
6 | - if !ok | |
7 | - raise "******** There are uncommited changes in the repository, cannot continue" | |
8 | - end | |
17 | + if !pendencies_on_repo[:ok] | |
18 | + raise "******** There are uncommited changes in the repository, cannot continue" | |
9 | 19 | end |
10 | 20 | end |
11 | 21 | |
... | ... | @@ -72,13 +82,101 @@ EOF |
72 | 82 | rm_f 'AUTHORS' |
73 | 83 | raise e |
74 | 84 | end |
85 | + if pendencies_on_authors[:res] | |
86 | + puts 'The AUTHORS file was updated!' | |
87 | + sh 'git diff AUTHORS' | |
88 | + if confirm('Do you want to commit this changes to the author file') | |
89 | + default_message = 'Updating AUTHORS file' | |
90 | + message = ask("Commit message [#{default_message}]:") | |
91 | + message = message.present? ? message : default_message | |
92 | + sh 'git add AUTHORS' | |
93 | + sh "git commit -m '#{message}'" | |
94 | + end | |
95 | + end | |
96 | + end | |
97 | + | |
98 | + def ask(message) | |
99 | + print message | |
100 | + STDIN.gets.chomp | |
101 | + end | |
102 | + | |
103 | + def confirm(message, default=true) | |
104 | + choice_message = default ? ' [Y/n]? ' : ' [y/N]? ' | |
105 | + choice = nil | |
106 | + while choice.nil? | |
107 | + answer = ask(message + choice_message) | |
108 | + if answer.blank? | |
109 | + choice = default | |
110 | + elsif ['y', 'yes'].include?(answer.downcase) | |
111 | + choice = true | |
112 | + elsif ['n', 'no'].include?(answer.downcase) | |
113 | + choice = false | |
114 | + end | |
115 | + end | |
116 | + choice | |
117 | + end | |
118 | + | |
119 | + desc 'sets the new version on apropriate files' | |
120 | + task :set_version, :release_kind do |t, args| | |
121 | + next if File.exist?("tmp/pending-release") | |
122 | + release_kind = args[:release_kind] || 'stable' | |
123 | + | |
124 | + if release_kind == 'test' | |
125 | + version_question = "Release candidate of which version: " | |
126 | + distribution = 'squeeze-test' | |
127 | + else | |
128 | + version_question = "Version that is being released: " | |
129 | + distribution = 'unstable' | |
130 | + end | |
131 | + | |
132 | + version_name = new_version = ask(version_question) | |
133 | + | |
134 | + if release_kind == 'test' | |
135 | + timestamp = Time.now.strftime('%Y%m%d%H%M%S') | |
136 | + version_name += "~rc#{timestamp}" | |
137 | + end | |
138 | + release_message = ask("Release message: ") | |
139 | + | |
140 | + sh 'git checkout debian/changelog lib/noosfero.rb' | |
141 | + sh "sed -i \"s/VERSION = '[^']*'/VERSION = '#{version_name}'/\" lib/noosfero.rb" | |
142 | + sh "dch --newversion #{version_name} --distribution #{distribution} --force-distribution '#{release_message}'" | |
143 | + | |
144 | + puts | |
145 | + if confirm("Commit version bump to #{version_name} on #{distribution} distribution") | |
146 | + sh 'git add debian/changelog lib/noosfero.rb' | |
147 | + sh "git commit -m 'Bumping version #{version_name}'" | |
148 | + sh "touch tmp/pending-release" | |
149 | + else | |
150 | + sh 'git checkout debian/changelog lib/noosfero.rb' | |
151 | + abort 'Version update not confirmed. Reverting changes and exiting...' | |
152 | + end | |
153 | + end | |
154 | + | |
155 | + desc "uploads the packages to the repository" | |
156 | + task :upload_packages, :release_kind do |t, args| | |
157 | + release_kind = args[:release_kind] || 'stable' | |
158 | + sh "dput --unchecked #{release_kind} #{Dir['pkg/*.changes'].first}" | |
75 | 159 | end |
76 | 160 | |
77 | 161 | 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}" | |
162 | + task :release, :release_kind do |t, args| | |
163 | + release_kind = args[:release_kind] || 'stable' | |
164 | + | |
165 | + Rake::Task['noosfero:set_version'].invoke(release_kind) | |
166 | + Rake::Task['noosfero:check_tag'].invoke | |
167 | + Rake::Task['noosfero:check_debian_package'].invoke | |
168 | + Rake::Task['noosfero:error-pages:translate'].invoke | |
169 | + Rake::Task['noosfero:authors'].invoke | |
170 | + Rake::Task['noosfero:check_repo'].invoke | |
171 | + Rake::Task['noosfero:debian_packages'].invoke | |
172 | + Rake::Task['noosfero:upload_packages'].invoke(release_kind) | |
173 | + | |
174 | + sh "git tag #{version.gsub('~','-')}" | |
175 | + push_tags = confirm('Push new version tag') | |
176 | + sh 'git push --tags' if push_tags | |
177 | + sh "rm tmp/pending-release" if Dir["tmp/pending-release"].first.present? | |
80 | 178 | 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!" | |
179 | + puts "I: please push the tag for version #{version} that was just created!" if !push_tags | |
82 | 180 | end |
83 | 181 | |
84 | 182 | desc 'Build Debian packages' | ... | ... |