@@ -4,11 +4,14 @@ skip_docs
4
4
require 'json'
5
5
require 'net/http'
6
6
7
- old_name = 'WebRTC'
8
- new_name = 'StreamWebRTC'
7
+ github_repo = ENV [ 'GITHUB_REPOSITORY' ] || 'GetStream/stream-video-swift-webrtc'
8
+ sdk_name = 'WebRTC'
9
+ modified_sdk_name = 'StreamWebRTC'
9
10
swift_package_path = '../Package.swift'
11
+ podspec_path = 'WebRTC.podspec'
10
12
11
13
lane :release do |options |
14
+ UI . user_error! ( "You must specify an xcframework path or livekit option" ) if options [ :xcframework_path ] . nil? && options [ :livekit ] . nil?
12
15
UI . user_error! ( "You must specify an xcframework version" ) unless options [ :version ]
13
16
UI . user_error! ( "Tag for version #{ options [ :version ] } already exists!" ) if git_tag_exists ( tag : options [ :version ] )
14
17
UI . success ( "Ignore the red warning above. Tag for version #{ options [ :version ] } is alright!" )
@@ -17,11 +20,20 @@ lane :release do |options|
17
20
sh ( "rm -rf *.xcframework" )
18
21
19
22
code_review
20
- download_framework ( version : options [ :version ] )
21
- rename_framework
22
23
23
- sh ( "ditto -c -k --sequesterRsrc --keepParent #{ new_name } .xcframework #{ new_name } .zip" )
24
- checksum = sh ( "swift package compute-checksum #{ new_name } .zip" ) . strip
24
+ options [ :xcframework_path ] = download_framework ( version : options [ :version ] ) if options [ :livekit ]
25
+
26
+ options [ :xcframework_path ] = unzip_xcframework ( file_path : options [ :xcframework_path ] )
27
+
28
+ options [ :xcframework_path ] = rename_framework if options [ :livekit ]
29
+
30
+ sign_xcframework ( file_path : options [ :xcframework_path ] )
31
+
32
+ options [ :xcframework_path ] = zip_xcframework ( file_path : options [ :xcframework_path ] )
33
+
34
+ checksum = sh ( "swift package compute-checksum #{ options [ :xcframework_path ] } " ) . strip
35
+
36
+ version_bump_podspec ( path : podspec_path , version_number : options [ :version ] )
25
37
26
38
file_data = ''
27
39
File . readlines ( swift_package_path ) . each do |line |
@@ -48,33 +60,28 @@ lane :release do |options|
48
60
UI . user_error! ( "Not pushing changes" ) unless prompt ( text : "Will push changes. All looking good?" , boolean : true )
49
61
sh ( 'git push' )
50
62
51
- github_release = set_github_release (
52
- repository_name : 'GetStream/stream-video-swift-webrtc' ,
53
- api_token : ENV . fetch ( "GITHUB_TOKEN" , nil ) ,
54
- name : options [ :version ] . to_s ,
55
- tag_name : options [ :version ] . to_s ,
56
- description : "Upgrade to WebRTC-SDK v#{ options [ :version ] } \n \n Checksum: #{ checksum } " ,
57
- commitish : git_branch ,
58
- upload_assets : [ "fastlane/#{ new_name } .zip" ]
63
+ publish_ios_sdk (
64
+ github_repo : github_repo ,
65
+ sdk_names : [ sdk_name ] ,
66
+ version : options [ :version ] ,
67
+ changelog : "Upgrade to WebRTC v#{ options [ :version ] } \n \n Checksum: #{ checksum } " ,
68
+ upload_assets : "fastlane/#{ options [ :xcframework_path ] } "
59
69
)
60
-
61
- UI . success ( "New SPM release available: #{ github_release [ 'html_url' ] } " )
62
70
end
63
71
64
- desc 'Example: bundle exec fastlane rename_framework path:WebRTC.xcframework'
65
- private_lane :rename_framework do |options |
66
- old_framework_path = File . expand_path ( "#{ old_name } .xcframework" )
67
- new_framework_path = old_framework_path . gsub ( /#{ old_name } / , new_name )
72
+ private_lane :rename_framework do
73
+ old_framework_path = File . expand_path ( "#{ sdk_name } .xcframework" )
74
+ new_framework_path = old_framework_path . gsub ( /#{ sdk_name } / , modified_sdk_name )
68
75
69
76
# Rename the framework itself
70
77
File . rename ( old_framework_path , new_framework_path )
71
78
72
79
# Rename all files with the old framework name with the new one
73
- [ "#{ old_name } .framework" , "#{ old_name } .h" , old_name ] . each do |file_name |
80
+ [ "#{ sdk_name } .framework" , "#{ sdk_name } .h" , sdk_name ] . each do |file_name |
74
81
Dir . glob ( "#{ new_framework_path } /**/*" ) . each do |old_file_path |
75
82
next unless File . basename ( old_file_path ) == file_name
76
83
77
- new_file_path = old_file_path . reverse . sub ( old_name . reverse , new_name . reverse ) . reverse
84
+ new_file_path = old_file_path . reverse . sub ( sdk_name . reverse , modified_sdk_name . reverse ) . reverse
78
85
File . rename ( old_file_path , new_file_path )
79
86
end
80
87
end
@@ -83,50 +90,59 @@ private_lane :rename_framework do |options|
83
90
Dir . glob ( [ "#{ new_framework_path } /**/Info.plist" , "#{ new_framework_path } /**/module.modulemap" ] ) . each do |file |
84
91
sh ( "plutil -convert xml1 #{ file } " ) if file . include? ( 'Info.plist' )
85
92
old_text = File . read ( file )
86
- new_text = old_text . gsub ( /#{ old_name } / , new_name )
93
+ new_text = old_text . gsub ( /#{ sdk_name } / , modified_sdk_name )
87
94
File . open ( file , 'w' ) { |f | f . puts ( new_text ) } if old_text != new_text
88
95
end
89
96
90
97
# Replace all imports of the old framework with the new one
91
98
Dir . glob ( "#{ new_framework_path } /**/*.h" ) . each do |file |
92
99
old_text = File . read ( file )
93
- new_text = old_text . gsub ( /import <#{ old_name } / , "import <#{ new_name } " )
100
+ new_text = old_text . gsub ( /import <#{ sdk_name } / , "import <#{ modified_sdk_name } " )
94
101
File . open ( file , 'w' ) { |f | f . puts ( new_text ) } if old_text != new_text
95
102
end
96
103
97
104
# Rename the rpath for all the frameworks and update symlinks if required
98
105
framework_paths = new_framework_path . include? ( '.xcframework' ) ? Dir . glob ( "#{ new_framework_path } /**/*.framework" ) : [ new_framework_path ]
99
106
framework_paths . each do |path |
100
107
Dir . chdir ( path ) do
101
- if File . symlink? ( new_name )
102
- old_symlink = File . readlink ( new_name )
103
- new_symlink = old_symlink . reverse . sub ( old_name . reverse , new_name . reverse ) . reverse
108
+ if File . symlink? ( modified_sdk_name )
109
+ old_symlink = File . readlink ( modified_sdk_name )
110
+ new_symlink = old_symlink . reverse . sub ( sdk_name . reverse , modified_sdk_name . reverse ) . reverse
104
111
105
- File . delete ( new_name )
106
- File . symlink ( new_symlink , new_name )
112
+ File . delete ( modified_sdk_name )
113
+ File . symlink ( new_symlink , modified_sdk_name )
107
114
end
108
115
109
- sh ( "install_name_tool -id @rpath/#{ new_name } .framework/#{ new_name } #{ new_name } " )
116
+ sh ( "install_name_tool -id @rpath/#{ modified_sdk_name } .framework/#{ modified_sdk_name } #{ modified_sdk_name } " )
110
117
end
111
118
end
119
+ new_framework_path
120
+ end
112
121
113
- # Sign xcframework if required
114
- if new_framework_path . include? ( '.xcframework' )
115
- team_id = File . read ( 'Matchfile' ) . match ( /team_id\( "(.*)"\) / ) [ 1 ]
116
- sh ( "codesign --force --timestamp -v --sign 'Apple Distribution: Stream.io Inc (#{ team_id } )' #{ new_framework_path } " )
117
- end
122
+ private_lane :sign_xcframework do |options |
123
+ team_id = File . read ( 'Matchfile' ) . match ( /team_id\( "(.*)"\) / ) [ 1 ]
124
+ sh ( "codesign --force --timestamp -v --sign 'Apple Distribution: Stream.io Inc (#{ team_id } )' #{ options [ :file_path ] } " )
118
125
end
119
126
120
127
private_lane :download_framework do |options |
121
128
UI . user_error! ( "You must specify an xcframework version" ) unless options [ :version ]
122
129
123
- url = "https://github.com/webrtc-sdk/Specs/releases/download/#{ options [ :version ] } /#{ old_name } .xcframework.zip"
124
- local_file_path = "#{ old_name } .xcframework.zip"
130
+ url = "https://github.com/webrtc-sdk/Specs/releases/download/#{ options [ :version ] } /#{ sdk_name } .xcframework.zip"
131
+ local_file_path = "#{ sdk_name } .xcframework.zip"
125
132
126
133
sh ( "wget '#{ url } ' -O '#{ local_file_path } '" )
134
+ local_file_path
135
+ end
136
+
137
+ private_lane :unzip_xcframework do |options |
138
+ sh ( "unzip '#{ options [ :file_path ] } '" )
139
+ File . basename ( options [ :file_path ] ) . gsub ( '.zip' , '' )
140
+ end
127
141
128
- # Extract the contents of the zip file
129
- sh ( "unzip '#{ local_file_path } '" )
142
+ private_lane :zip_xcframework do |options |
143
+ zip_name = "#{ options [ :file_path ] } .zip"
144
+ sh ( "ditto -c -k --sequesterRsrc --keepParent #{ options [ :file_path ] } #{ zip_name } " )
145
+ zip_name
130
146
end
131
147
132
148
lane :code_review do
0 commit comments