Skip to content

Commit

Permalink
ci: Fix TestFlight upload for previews (getsentry#972)
Browse files Browse the repository at this point in the history
App Store connect requires a period-separated list of at most three non-negative integers
for the version. Therefore the version bump script must not add the suffixes of preview
releases. This is fixed now.
  • Loading branch information
philipphofmann authored Mar 4, 2021
1 parent d89f3b0 commit fa45ab0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ jobs:
run: bundle exec fastlane bump_bundle_version
shell: sh

- name: Remove preview version suffixes
run: bundle exec fastlane remove_preview_version_suffixes
shell: sh

- name: Run Fastlane
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
Expand Down
4 changes: 2 additions & 2 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.0.0-alpha.0;
MARKETING_VERSION = "7.0.0-alpha.0";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = NO;
Expand All @@ -423,7 +423,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.0.0-alpha.0;
MARKETING_VERSION = "7.0.0-alpha.0";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift";
Expand Down
4 changes: 1 addition & 3 deletions Utils/VersionBump/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ let package = Package(
.executable(name: "VersionBump", targets: ["VersionBump"])
],
dependencies: [
// We need to use the 5.1.0-beta.1, because otherwise we can't compile with Swift 5.3
// see https://github.com/kareman/SwiftShell/releases/tag/5.1.0-beta.1
.package(url: "https://github.com/kareman/SwiftShell.git", from: "5.1.0-beta.1"),
.package(url: "https://github.com/kareman/SwiftShell.git", from: "5.1.0"),
.package(url: "https://github.com/sharplet/Regex.git", from: "2.1.1")
],
targets: [
Expand Down
16 changes: 10 additions & 6 deletions Utils/VersionBump/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ for match in Regex(semver, options: [.dotMatchesLineSeparators]).allMatches(in:
let toVersion = args[1]

for file in files {
let readFile = try open(file)
let contents: String = readFile.read()
let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
let overwriteFile = try! open(forWriting: file, overwrite: true)
overwriteFile.write(newContents)
overwriteFile.close()
try updateVersion(file, fromVersion, toVersion)
}
}

func updateVersion(_ file: String, _ fromVersion: String, _ toVersion: String) throws {
let readFile = try open(file)
let contents: String = readFile.read()
let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
let overwriteFile = try! open(forWriting: file, overwrite: true)
overwriteFile.write(newContents)
overwriteFile.close()
}
30 changes: 29 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,40 @@ platform :ios do
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
team_id = CredentialsManager::AppfileConfig.try_fetch_value(:team_id)

ioSwiftInfoPlistPath = "./Samples/iOS-Swift/iOS-Swift/Info.plist"

lane :bump_bundle_version do
set_info_plist_value(
path: "./Samples/iOS-Swift/iOS-Swift/Info.plist",
path: ioSwiftInfoPlistPath,
key: "CFBundleVersion",
value: ENV["FASTLANE_BUNDLE_VERSION"]
)

end

# The version for all Info.plist must be a period-separated list of at most three non-negative integers
# for App Store Connect. If we are on a preview we to remove these suffixes.
lane :remove_preview_version_suffixes do
version = get_version_number(xcodeproj: "./Samples/iOS-Swift/iOS-Swift.xcodeproj")
version = version.split("-", -1)[0]

set_info_plist_value(
path: ioSwiftInfoPlistPath,
key: "CFBundleShortVersionString",
value: version
)

sentryInfoPlistPath = "./Sources/Sentry/Info.plist"
set_info_plist_value(
path: sentryInfoPlistPath,
key: "CFBundleShortVersionString",
value: version
)
set_info_plist_value(
path: sentryInfoPlistPath,
key: "CFBundleVersion",
value: version
)
end

desc "Upload iOS-Swift to TestFlight and symbols to Sentry"
Expand Down

0 comments on commit fa45ab0

Please sign in to comment.