Skip to content

Helper to update version branches like 4-0-dev #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ namespace :dev do
end

namespace :git do
desc 'create version branch'
task :create_version_branch do
unless ENV['BRANCH'] && ENV['VERSION']
puts "Please specify a branch and a version .e.g"
puts "BRANCH='4-0-dev' VERSION='4.0.0.pre' rake git:create_version_branch"
exit(1)
end

branch = ENV['BRANCH']
version = ENV['VERSION']

each_project do |project|
if system("git show-branch #{branch} > /dev/null 2>&1")
sh "git checkout #{branch}"
else
sh "git checkout -b #{branch} main"
end

update_maintenance_branch(true)
update_version_file(project, version)

sh "git add ."
sh "git ci -m 'Update version to #{version}'"
end
force_update(branch, nil)
end

{ :status => nil, :push => nil, :reset => '--hard', :diff => nil }.each do |command, options|
desc "git #{command} on all the repos"
task command => :clone do
Expand Down Expand Up @@ -295,8 +322,13 @@ namespace :ci do
Dir.mkdir(dirname)
end

def update_maintenance_branch
File.write("./maintenance-branch", BASE_BRANCH) unless File.exist?('./maintenance-branch')
def update_maintenance_branch(override = false)
File.write("./maintenance-branch", BASE_BRANCH) if override || !File.exist?('./maintenance-branch')
end

def update_version_file(repo, version)
full_file_name = ReposPath.join(repo, "lib/#{repo.gsub('-','/')}/version.rb")
full_file_name.write(full_file_name.read.gsub(/(STRING = ['"])(.*)(['"])/, "STRING = '#{version}'"))
end

def run_if_exists(script_file)
Expand Down