Skip to content
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

[CI] Create a lane to update StreamChat dependency #687

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.67.0"),
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.68.0"),
],
targets: [
.target(
Expand Down
34 changes: 34 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,40 @@ private_lane :appstore_api_key do
)
end

desc "Updates StreamChat dependency locally. Usage: `bundle exec fastlane update_stream_chat version:4.56.0`"
lane :update_stream_chat do |options|
raise UI.user_error!('Provide a version.') unless options[:version]

Dir.chdir('..') do
file = 'Package.swift'
current_stream_chat_version = File.read(file)[/stream-chat-swift\.git", from: "([\d.]+)"\)/, 1]
File.write(file, File.read(file).gsub(/(stream-chat-swift\.git", from: ")[\d.]+"/, "\\1#{options[:version]}\""))

file = 'StreamChatSwiftUI-XCFramework.podspec'
File.write(file, File.read(file).gsub(/(StreamChat-XCFramework', '~> )[\d.]+'/, "\\1#{options[:version]}'"))

file = 'StreamChatSwiftUI.podspec'
File.write(file, File.read(file).gsub(/(StreamChat', '~> )[\d.]+'/, "\\1#{options[:version]}'"))

file = 'StreamChatSwiftUI.xcodeproj/project.pbxproj'
content = File.read(file)
if content.include?("minimumVersion = #{current_stream_chat_version}")
File.write(file, content.gsub("minimumVersion = #{current_stream_chat_version}", "minimumVersion = #{options[:version]}"))
elsif content.include?('branch = develop')
File.write(file, content.gsub('kind = branch', "minimumVersion = #{options[:version]}").gsub('branch = develop', 'kind = upToNextMajorVersion'))
else
UI.user_error!("Something went wrong after trying to modify #{file}.")
end
Comment on lines +164 to +172
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should check for stream chat since there are multiple dependencies. Not sure if it is a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it actually makes things much more complex. A chance that we will hit a different dependency with the same key minimumVersion = #{current_stream_chat_version} is very low. We also do not use other dependencies from develop ever.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably fine. We can improve it if really need to. Makes sense to not complicate this too much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this will work fine 👍 Once we add a new dependency, this will break and then we will know that we need to update this 😄

end

pr_create(
title: "Update StreamChat dependency to #{options[:version]}",
base_branch: 'develop',
head_branch: "ci/update-stream-chat-dependency-#{Time.now.to_i}",
github_repo: github_repo
)
end

lane :pod_lint do
lint_required = true
Dir.chdir('..') do
Expand Down
Loading