From ec1e4900c358db464ddee02f4b23834e1a45896a Mon Sep 17 00:00:00 2001 From: Chris McGee Date: Sat, 5 Apr 2025 07:03:27 -0400 Subject: [PATCH 1/2] Move release 1.0 to swift 6.1 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 39c5d6a6..358e78e6 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -6.0.3 \ No newline at end of file +6.1.0 \ No newline at end of file From 18face02a16f93355bb369bf140cfc6ed8dff7b7 Mon Sep 17 00:00:00 2001 From: Chris McGee Date: Sun, 6 Apr 2025 07:32:44 -0400 Subject: [PATCH 2/2] Update swift version check regexes in build script to work with swift at no minor version --- .../BuildSwiftlyRelease.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Tools/build-swiftly-release/BuildSwiftlyRelease.swift b/Tools/build-swiftly-release/BuildSwiftlyRelease.swift index 38a863f0..d67d5a90 100644 --- a/Tools/build-swiftly-release/BuildSwiftlyRelease.swift +++ b/Tools/build-swiftly-release/BuildSwiftlyRelease.swift @@ -103,7 +103,7 @@ public func runProgramOutput(_ program: String, _ args: String...) async throws throw Error(message: "\(args.first!) exited with non-zero status: \(process.terminationStatus)") } - if let outData = outData { + if let outData { return String(data: outData, encoding: .utf8) } else { return nil @@ -203,7 +203,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand { if FileManager.default.fileExists(atPath: svFile.path) { let selector = try? String(contentsOf: svFile, encoding: .utf8) - if let selector = selector { + if let selector { return selector.replacingOccurrences(of: "\n", with: "") } return selector @@ -220,10 +220,14 @@ struct BuildSwiftlyRelease: AsyncParsableCommand { return try await self.assertTool("swift", message: "Please install swift and make sure that it is added to your path.") } - guard let requiredSwiftVersion = try? self.findSwiftVersion() else { + guard var requiredSwiftVersion = try? self.findSwiftVersion() else { throw Error(message: "Unable to determine the required swift version for this version of swiftly. Please make sure that you `cd ` and there is a .swift-version file there.") } + if requiredSwiftVersion.hasSuffix(".0") { + requiredSwiftVersion = String(requiredSwiftVersion.dropLast(2)) + } + let swift = try await self.assertTool("swift", message: "Please install swift \(requiredSwiftVersion) and make sure that it is added to your path.") // We also need a swift toolchain with the correct version @@ -287,7 +291,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand { try? FileManager.default.createDirectory(atPath: pkgConfigPath, withIntermediateDirectories: true) try? FileManager.default.removeItem(atPath: libArchivePath) - try runProgram(curl, "-o", "\(buildCheckoutsDir + "/libarchive-\(libArchiveVersion).tar.gz")", "--remote-name", "--location", "https://github.com/libarchive/libarchive/releases/download/v\(libArchiveVersion)/libarchive-\(libArchiveVersion).tar.gz") + try runProgram(curl, "-L", "-o", "\(buildCheckoutsDir + "/libarchive-\(libArchiveVersion).tar.gz")", "--remote-name", "--location", "https://github.com/libarchive/libarchive/releases/download/v\(libArchiveVersion)/libarchive-\(libArchiveVersion).tar.gz") let libArchiveTarShaActual = try await runProgramOutput(sha256sum, "\(buildCheckoutsDir)/libarchive-\(libArchiveVersion).tar.gz") guard let libArchiveTarShaActual, libArchiveTarShaActual.starts(with: libArchiveTarSha) else { let shaActual = libArchiveTarShaActual ?? "none" @@ -298,7 +302,8 @@ struct BuildSwiftlyRelease: AsyncParsableCommand { let cwd = FileManager.default.currentDirectoryPath FileManager.default.changeCurrentDirectoryPath(libArchivePath) - let swiftVerRegex: Regex<(Substring, Substring)> = try! Regex("Swift version (\\d+\\.\\d+\\.\\d+) ") + let swiftVerRegex: Regex<(Substring, Substring)> = try! Regex("Swift version (\\d+\\.\\d+\\.?\\d*) ") + let swiftVerOutput = (try await runProgramOutput(swift, "--version")) ?? "" guard let swiftVerMatch = try swiftVerRegex.firstMatch(in: swiftVerOutput) else { throw Error(message: "Unable to detect swift version")