@@ -152,6 +152,33 @@ namespace :dev do
152
152
end
153
153
154
154
namespace :git do
155
+ desc 'create version branch'
156
+ task :create_version_branch do
157
+ unless ENV [ 'BRANCH' ] && ENV [ 'VERSION' ]
158
+ puts "Please specify a branch and a version .e.g"
159
+ puts "BRANCH='4-0-dev' VERSION='4.0.0.pre' rake git:create_version_branch"
160
+ exit ( 1 )
161
+ end
162
+
163
+ branch = ENV [ 'BRANCH' ]
164
+ version = ENV [ 'VERSION' ]
165
+
166
+ each_project do |project |
167
+ if system ( "git show-branch #{ branch } > /dev/null 2>&1" )
168
+ sh "git checkout #{ branch } "
169
+ else
170
+ sh "git checkout -b #{ branch } main"
171
+ end
172
+
173
+ update_maintenance_branch ( true )
174
+ update_version_file ( project , version )
175
+
176
+ sh "git add ."
177
+ sh "git ci -m 'Update version to #{ version } '"
178
+ end
179
+ force_update ( branch , nil )
180
+ end
181
+
155
182
{ :status => nil , :push => nil , :reset => '--hard' , :diff => nil } . each do |command , options |
156
183
desc "git #{ command } on all the repos"
157
184
task command => :clone do
@@ -295,8 +322,13 @@ namespace :ci do
295
322
Dir . mkdir ( dirname )
296
323
end
297
324
298
- def update_maintenance_branch
299
- File . write ( "./maintenance-branch" , BASE_BRANCH ) unless File . exist? ( './maintenance-branch' )
325
+ def update_maintenance_branch ( override = false )
326
+ File . write ( "./maintenance-branch" , BASE_BRANCH ) if override || !File . exist? ( './maintenance-branch' )
327
+ end
328
+
329
+ def update_version_file ( repo , version )
330
+ full_file_name = ReposPath . join ( repo , "lib/#{ repo . gsub ( '-' , '/' ) } /version.rb" )
331
+ full_file_name . write ( full_file_name . read . gsub ( /(STRING = ['"])(.*)(['"])/ , "STRING = '#{ version } '" ) )
300
332
end
301
333
302
334
def run_if_exists ( script_file )
0 commit comments