Skip to content

Commit

Permalink
[CI] Automatically update SDK size badges in README.md (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored Jul 30, 2024
1 parent ce6becb commit 2a63ee4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<p align="center">
<a href="https://sonarcloud.io/summary/new_code?id=GetStream_stream-chat-swiftui"><img src="https://sonarcloud.io/api/project_badges/measure?project=GetStream_stream-chat-swiftui&metric=coverage" /></a>

<img id="stream-chat-swiftui-label" alt="StreamChatSwiftUI" src="https://img.shields.io/badge/StreamChatSwiftUI-6.96MB-blue"/>
</p>

## SwiftUI StreamChat SDK
Expand Down
24 changes: 24 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ lane :release do |options|
# Set the framework version in SystemEnvironment+Version.swift
new_content = File.read(swift_environment_path).gsub!(previous_version_number, release_version)
File.open(swift_environment_path, 'w') { |f| f.puts(new_content) }

# Update sdk sizes
Dir.chdir('fastlane') { update_img_shields_sdk_sizes }
end

pod_lint
Expand Down Expand Up @@ -542,6 +545,27 @@ lane :show_frameworks_sizes do |options|
UI.user_error!("#{table_header} benchmark failed.") if markdown_table.include?(fail_status)
end

desc 'Update img shields SDK size labels'
lane :update_img_shields_sdk_sizes do
sizes = frameworks_sizes

# Read the file into a string
readme_path = '../README.md'
readme_content = File.read(readme_path)

# Define the new value for the badge
stream_chat_swiftui_size = "#{sizes[:StreamChatSwiftUI]}MB"

# Replace the value in the badge URL
readme_content.gsub!(%r{(https://img.shields.io/badge/StreamChatSwiftUI-)(.*?)(-blue)}, "\\1#{stream_chat_swiftui_size}\\3")

# Write the updated content back to the file
File.write(readme_path, readme_content)

# Notify success
UI.success('Successfully updated the SDK size labels in README.md!')
end

def frameworks_sizes
root_dir = 'Build/SDKSize'
archive_dir = "#{root_dir}/DemoApp.xcarchive"
Expand Down

0 comments on commit 2a63ee4

Please sign in to comment.