@@ -146,6 +146,40 @@ private_lane :appstore_api_key do
146146 )
147147end
148148
149+ desc "Updates StreamChat dependency locally. Usage: `bundle exec fastlane update_stream_chat version:4.56.0`"
150+ lane :update_stream_chat do |options |
151+ raise UI . user_error! ( 'Provide a version.' ) unless options [ :version ]
152+
153+ Dir . chdir ( '..' ) do
154+ file = 'Package.swift'
155+ current_stream_chat_version = File . read ( file ) [ /stream-chat-swift\. git", from: "([\d .]+)"\) / , 1 ]
156+ File . write ( file , File . read ( file ) . gsub ( /(stream-chat-swift\. git", from: ")[\d .]+"/ , "\\ 1#{ options [ :version ] } \" " ) )
157+
158+ file = 'StreamChatSwiftUI-XCFramework.podspec'
159+ File . write ( file , File . read ( file ) . gsub ( /(StreamChat-XCFramework', '~> )[\d .]+'/ , "\\ 1#{ options [ :version ] } '" ) )
160+
161+ file = 'StreamChatSwiftUI.podspec'
162+ File . write ( file , File . read ( file ) . gsub ( /(StreamChat', '~> )[\d .]+'/ , "\\ 1#{ options [ :version ] } '" ) )
163+
164+ file = 'StreamChatSwiftUI.xcodeproj/project.pbxproj'
165+ content = File . read ( file )
166+ if content . include? ( "minimumVersion = #{ current_stream_chat_version } " )
167+ File . write ( file , content . gsub ( "minimumVersion = #{ current_stream_chat_version } " , "minimumVersion = #{ options [ :version ] } " ) )
168+ elsif content . include? ( 'branch = develop' )
169+ File . write ( file , content . gsub ( 'kind = branch' , "minimumVersion = #{ options [ :version ] } " ) . gsub ( 'branch = develop' , 'kind = upToNextMajorVersion' ) )
170+ else
171+ UI . user_error! ( "Something went wrong after trying to modify #{ file } ." )
172+ end
173+ end
174+
175+ pr_create (
176+ title : "Update StreamChat dependency to #{ options [ :version ] } " ,
177+ base_branch : 'develop' ,
178+ head_branch : "ci/update-stream-chat-dependency-#{ Time . now . to_i } " ,
179+ github_repo : github_repo
180+ )
181+ end
182+
149183lane :pod_lint do
150184 lint_required = true
151185 Dir . chdir ( '..' ) do
0 commit comments