Skip to content

Commit 6f5a936

Browse files
authored
Versioning script (#887)
* Changes versioning script similar to Swift SDK. * Update check_version script also.
1 parent 2401f9b commit 6f5a936

5 files changed

Lines changed: 417 additions & 26 deletions

File tree

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.5.1

ios/livekit_client.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'livekit_client'
3-
s.version = '2.5.0'
3+
s.version = '2.5.1'
44
s.summary = 'Open source platform for real-time audio and video.'
55
s.description = 'Open source platform for real-time audio and video.'
66
s.homepage = 'https://livekit.io/'

macos/livekit_client.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'livekit_client'
3-
s.version = '2.5.0'
3+
s.version = '2.5.1'
44
s.summary = 'Open source platform for real-time audio and video.'
55
s.description = 'Open source platform for real-time audio and video.'
66
s.homepage = 'https://livekit.io/'

scripts/check_version.dart

100644100755
Lines changed: 101 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,116 @@
1+
#!/usr/bin/env dart
2+
/*
3+
* Copyright 2025 LiveKit
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
import 'dart:io';
219

320
import 'package:yaml/yaml.dart';
421

5-
void main() {
6-
final File pubspec = File('pubspec.yaml');
7-
final doc = loadYaml(pubspec.readAsStringSync());
8-
final versionStr = doc['version'];
22+
class _Path {
23+
static const pubspec = 'pubspec.yaml';
24+
static const iosPodspec = 'ios/livekit_client.podspec';
25+
static const macosPodspec = 'macos/livekit_client.podspec';
26+
static const livekitVersion = 'lib/src/livekit.dart';
27+
}
928

10-
final RegExpMatch? match = RegExp(r'(\d+\.\d+\.\d+)').firstMatch(versionStr);
29+
class _Pattern {
30+
static final semanticVersion = RegExp(r'(\d+\.\d+\.\d+)');
31+
static final webrtcSdkVersion = RegExp(r"s\.dependency\s+'WebRTC-SDK',\s+'([^']+)'");
32+
}
1133

12-
final version = match?[0];
34+
class _Color {
35+
static const reset = '\x1B[0m';
36+
static const green = '\x1B[32m';
37+
static const bold = '\x1B[1m';
38+
}
1339

14-
if (version == null) {
15-
// ignore: avoid_print
16-
print('Could not find version in pubspec.yaml');
17-
exit(1);
40+
String readFile(String path) {
41+
try {
42+
return File(path).readAsStringSync();
43+
} catch (e) {
44+
throw Exception('Failed to read $path: $e');
45+
}
46+
}
47+
48+
String extractVersionFromPubspec() {
49+
final content = readFile(_Path.pubspec);
50+
final doc = loadYaml(content);
51+
final versionStr = doc['version'];
52+
53+
final match = _Pattern.semanticVersion.firstMatch(versionStr);
54+
if (match == null) {
55+
throw Exception('Could not find version in ${_Path.pubspec}');
1856
}
1957

20-
print('Checking version $version');
58+
return match.group(0)!;
59+
}
2160

22-
final files = [
23-
'ios/livekit_client.podspec',
24-
'macos/livekit_client.podspec',
25-
'lib/src/livekit.dart'
61+
void checkVersionConsistency(String expectedVersion) {
62+
final filesToCheck = [
63+
_Path.iosPodspec,
64+
_Path.macosPodspec,
65+
_Path.livekitVersion,
2666
];
2767

28-
for (var file in files) {
29-
final content = File(file).readAsStringSync();
30-
if (!content.contains(version)) {
31-
final RegExp exp = RegExp(r'(\d+\.\d+\.\d+)');
32-
final RegExpMatch? match = exp.firstMatch(content);
33-
// ignore: avoid_print
34-
print(
35-
'Version mismatch in $file, pubspec.yaml version is $version != ${match![0]} in $file, please update');
36-
exit(1);
68+
for (final file in filesToCheck) {
69+
final content = readFile(file);
70+
if (!content.contains(expectedVersion)) {
71+
final match = _Pattern.semanticVersion.firstMatch(content);
72+
final foundVersion = match?.group(0) ?? 'unknown';
73+
throw Exception('Version mismatch in $file: expected $expectedVersion, found $foundVersion');
3774
}
3875
}
3976
}
77+
78+
void checkWebRtcSdkVersions() {
79+
final iosPodspec = readFile(_Path.iosPodspec);
80+
final macosPodspec = readFile(_Path.macosPodspec);
81+
82+
final iosMatch = _Pattern.webrtcSdkVersion.firstMatch(iosPodspec);
83+
final macosMatch = _Pattern.webrtcSdkVersion.firstMatch(macosPodspec);
84+
85+
if (iosMatch == null) {
86+
throw Exception('Could not find WebRTC-SDK version in ${_Path.iosPodspec}');
87+
}
88+
89+
if (macosMatch == null) {
90+
throw Exception('Could not find WebRTC-SDK version in ${_Path.macosPodspec}');
91+
}
92+
93+
final iosVersion = iosMatch.group(1)!;
94+
final macosVersion = macosMatch.group(1)!;
95+
96+
if (iosVersion != macosVersion) {
97+
throw Exception('WebRTC-SDK version mismatch: iOS=$iosVersion, macOS=$macosVersion');
98+
}
99+
100+
print('${_Color.green}WebRTC-SDK versions match: $iosVersion${_Color.reset}');
101+
}
102+
103+
void main() {
104+
try {
105+
final version = extractVersionFromPubspec();
106+
print('Checking version ${_Color.bold}${_Color.green}$version${_Color.reset}');
107+
108+
checkVersionConsistency(version);
109+
checkWebRtcSdkVersions();
110+
111+
print('${_Color.bold}${_Color.green}All version checks passed ✓${_Color.reset}');
112+
} catch (e) {
113+
print('Error: $e');
114+
exit(1);
115+
}
116+
}

0 commit comments

Comments
 (0)