@@ -103,7 +103,7 @@ public func runProgramOutput(_ program: String, _ args: String...) async throws
103103 throw Error ( message: " \( args. first!) exited with non-zero status: \( process. terminationStatus) " )
104104 }
105105
106- if let outData = outData {
106+ if let outData {
107107 return String ( data: outData, encoding: . utf8)
108108 } else {
109109 return nil
@@ -203,7 +203,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
203203
204204 if FileManager . default. fileExists ( atPath: svFile. path) {
205205 let selector = try ? String ( contentsOf: svFile, encoding: . utf8)
206- if let selector = selector {
206+ if let selector {
207207 return selector. replacingOccurrences ( of: " \n " , with: " " )
208208 }
209209 return selector
@@ -220,10 +220,14 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
220220 return try await self . assertTool ( " swift " , message: " Please install swift and make sure that it is added to your path. " )
221221 }
222222
223- guard let requiredSwiftVersion = try ? self . findSwiftVersion ( ) else {
223+ guard var requiredSwiftVersion = try ? self . findSwiftVersion ( ) else {
224224 throw Error ( message: " Unable to determine the required swift version for this version of swiftly. Please make sure that you `cd <swiftly_git_dir>` and there is a .swift-version file there. " )
225225 }
226226
227+ if requiredSwiftVersion. hasSuffix ( " .0 " ) {
228+ requiredSwiftVersion = String ( requiredSwiftVersion. dropLast ( 2 ) )
229+ }
230+
227231 let swift = try await self . assertTool ( " swift " , message: " Please install swift \( requiredSwiftVersion) and make sure that it is added to your path. " )
228232
229233 // We also need a swift toolchain with the correct version
@@ -287,7 +291,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
287291 try ? FileManager . default. createDirectory ( atPath: pkgConfigPath, withIntermediateDirectories: true )
288292
289293 try ? FileManager . default. removeItem ( atPath: libArchivePath)
290- 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 " )
294+ 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 " )
291295 let libArchiveTarShaActual = try await runProgramOutput ( sha256sum, " \( buildCheckoutsDir) /libarchive- \( libArchiveVersion) .tar.gz " )
292296 guard let libArchiveTarShaActual, libArchiveTarShaActual. starts ( with: libArchiveTarSha) else {
293297 let shaActual = libArchiveTarShaActual ?? " none "
@@ -298,7 +302,8 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
298302 let cwd = FileManager . default. currentDirectoryPath
299303 FileManager . default. changeCurrentDirectoryPath ( libArchivePath)
300304
301- let swiftVerRegex : Regex < ( Substring , Substring ) > = try ! Regex ( " Swift version ( \\ d+ \\ . \\ d+ \\ . \\ d+) " )
305+ let swiftVerRegex : Regex < ( Substring , Substring ) > = try ! Regex ( " Swift version ( \\ d+ \\ . \\ d+ \\ .? \\ d*) " )
306+
302307 let swiftVerOutput = ( try await runProgramOutput ( swift, " --version " ) ) ?? " "
303308 guard let swiftVerMatch = try swiftVerRegex. firstMatch ( in: swiftVerOutput) else {
304309 throw Error ( message: " Unable to detect swift version " )
0 commit comments