From 4eea4d126249061e4f8e641195c0b0b21911fbf8 Mon Sep 17 00:00:00 2001 From: Dhiogo Brustolin Date: Wed, 2 Oct 2024 14:07:58 +0200 Subject: [PATCH] Chore: Fix the versioning to support app release with Beta versions (#4368) * Update main.swift * Fixing xcconfig version * Update main.swift * Update SentryTests.m * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ Sources/Configuration/SDK.xcconfig | 2 +- Sources/Configuration/SentrySwiftUI.xcconfig | 2 +- Tests/SentryTests/SentryTests.m | 15 ------------ Utils/VersionBump/main.swift | 25 ++++++++++++++++---- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3e5ec6554..74c4f42213b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ - Slightly speed up SentryInAppLogic (#4370) - Stop canceling timer for manual transactions (#4380) +### Fixes + +- Fix the versioning to support app release with Beta versions (#4368) + ## 8.37.0-beta.1 ### Features diff --git a/Sources/Configuration/SDK.xcconfig b/Sources/Configuration/SDK.xcconfig index 8787c17df8c..e25be24877a 100644 --- a/Sources/Configuration/SDK.xcconfig +++ b/Sources/Configuration/SDK.xcconfig @@ -10,7 +10,7 @@ DYLIB_INSTALL_NAME_BASE = @rpath MACH_O_TYPE = mh_dylib FRAMEWORK_VERSION = A -CURRENT_PROJECT_VERSION = 8.37.0-beta.1 +CURRENT_PROJECT_VERSION = 8.37.0 ALWAYS_SEARCH_USER_PATHS = NO CLANG_ENABLE_OBJC_ARC = YES diff --git a/Sources/Configuration/SentrySwiftUI.xcconfig b/Sources/Configuration/SentrySwiftUI.xcconfig index fb5410ac6f3..6c76b66635e 100644 --- a/Sources/Configuration/SentrySwiftUI.xcconfig +++ b/Sources/Configuration/SentrySwiftUI.xcconfig @@ -1,5 +1,5 @@ PRODUCT_NAME = SentrySwiftUI -CURRENT_PROJECT_VERSION = 7.31.3 +CURRENT_PROJECT_VERSION = 8.37.0 MACOSX_DEPLOYMENT_TARGET = 10.15 IPHONEOS_DEPLOYMENT_TARGET = 13.0 diff --git a/Tests/SentryTests/SentryTests.m b/Tests/SentryTests/SentryTests.m index 74162b2853c..a539838e442 100644 --- a/Tests/SentryTests/SentryTests.m +++ b/Tests/SentryTests/SentryTests.m @@ -31,21 +31,6 @@ - (void)setUp [SentrySDK.currentHub bindClient:nil]; } -- (void)testVersion -{ - NSDictionary *info = [[NSBundle bundleForClass:[SentryClient class]] infoDictionary]; - NSString *version = [NSString stringWithFormat:@"%@", info[@"CFBundleShortVersionString"]]; - if ([info[@"CFBundleIdentifier"] isEqualToString:@"io.sentry.Sentry"]) { - // This test is running on a bundle that is not the SDK - // (code was loaded inside an app for example) - // in this case, we don't care about asserting our hard coded value matches - // since this will be the app version instead of our SDK version. - XCTAssert([version isEqualToString:SentryMeta.versionString], - @"Version of bundle:%@ not equal to version of SentryMeta:%@", version, - SentryMeta.versionString); - } -} - - (void)testSharedClient { NSError *error = nil; diff --git a/Utils/VersionBump/main.swift b/Utils/VersionBump/main.swift index 64b46487c71..e4cda5fc465 100644 --- a/Utils/VersionBump/main.swift +++ b/Utils/VersionBump/main.swift @@ -10,12 +10,17 @@ let files = [ "./SentryPrivate.podspec", "./SentrySwiftUI.podspec", "./Sources/Sentry/SentryMeta.m", - "./Sources/Configuration/SDK.xcconfig", - "./Sources/Configuration/SentrySwiftUI.xcconfig", "./Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj", "./Tests/HybridSDKTest/HybridPod.podspec" ] +// Files that only accept the format x.x.x in order to release an app using the framework. +// This will enable publishing apps with SDK beta version. +let restrictFiles = [ + "./Sources/Configuration/SDK.xcconfig", + "./Sources/Configuration/SentrySwiftUI.xcconfig" +] + let args = CommandLine.arguments let semver: StaticString = "([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?" @@ -28,12 +33,19 @@ let fromVersionFileHandler = try open(fromVersionFile) let fromFileContent: String = fromVersionFileHandler.read() if let match = Regex(semver, options: [.dotMatchesLineSeparators]).firstMatch(in: fromFileContent) { - let fromVersion = match.matchedString - let toVersion = args[1] + var fromVersion = match.matchedString + var toVersion = args[1] for file in files { try updateVersion(file, fromVersion, toVersion) } + + fromVersion = extractVersionOnly(fromVersion) + toVersion = extractVersionOnly(toVersion) + + for file in restrictFiles { + try updateVersion(file, fromVersion, toVersion) + } } func updateVersion(_ file: String, _ fromVersion: String, _ toVersion: String) throws { @@ -44,3 +56,8 @@ func updateVersion(_ file: String, _ fromVersion: String, _ toVersion: String) t overwriteFile.write(newContents) overwriteFile.close() } + +func extractVersionOnly(_ version: String) -> String { + guard let indexOfHypen = version.firstIndex(of: "-") else { return version } + return String(version.prefix(upTo: indexOfHypen)) +}