Skip to content

Commit

Permalink
Chore: Fix the versioning to support app release with Beta versions (#…
Browse files Browse the repository at this point in the history
…4368)

* Update main.swift

* Fixing xcconfig version

* Update main.swift

* Update SentryTests.m

* Update CHANGELOG.md
  • Loading branch information
brustolin authored Oct 2, 2024
1 parent fd458ae commit 4eea4d1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Configuration/SDK.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Configuration/SentrySwiftUI.xcconfig
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 0 additions & 15 deletions Tests/SentryTests/SentryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 21 additions & 4 deletions Utils/VersionBump/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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-]+)?"
Expand All @@ -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 {
Expand All @@ -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))
}

0 comments on commit 4eea4d1

Please sign in to comment.