@@ -103,7 +103,7 @@ public func runProgramOutput(_ program: String, _ args: String...) async throws
103
103
throw Error ( message: " \( args. first!) exited with non-zero status: \( process. terminationStatus) " )
104
104
}
105
105
106
- if let outData = outData {
106
+ if let outData {
107
107
return String ( data: outData, encoding: . utf8)
108
108
} else {
109
109
return nil
@@ -203,7 +203,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
203
203
204
204
if FileManager . default. fileExists ( atPath: svFile. path) {
205
205
let selector = try ? String ( contentsOf: svFile, encoding: . utf8)
206
- if let selector = selector {
206
+ if let selector {
207
207
return selector. replacingOccurrences ( of: " \n " , with: " " )
208
208
}
209
209
return selector
@@ -220,10 +220,14 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
220
220
return try await self . assertTool ( " swift " , message: " Please install swift and make sure that it is added to your path. " )
221
221
}
222
222
223
- guard let requiredSwiftVersion = try ? self . findSwiftVersion ( ) else {
223
+ guard var requiredSwiftVersion = try ? self . findSwiftVersion ( ) else {
224
224
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. " )
225
225
}
226
226
227
+ if requiredSwiftVersion. hasSuffix ( " .0 " ) {
228
+ requiredSwiftVersion = String ( requiredSwiftVersion. dropLast ( 2 ) )
229
+ }
230
+
227
231
let swift = try await self . assertTool ( " swift " , message: " Please install swift \( requiredSwiftVersion) and make sure that it is added to your path. " )
228
232
229
233
// We also need a swift toolchain with the correct version
@@ -287,7 +291,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
287
291
try ? FileManager . default. createDirectory ( atPath: pkgConfigPath, withIntermediateDirectories: true )
288
292
289
293
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 " )
291
295
let libArchiveTarShaActual = try await runProgramOutput ( sha256sum, " \( buildCheckoutsDir) /libarchive- \( libArchiveVersion) .tar.gz " )
292
296
guard let libArchiveTarShaActual, libArchiveTarShaActual. starts ( with: libArchiveTarSha) else {
293
297
let shaActual = libArchiveTarShaActual ?? " none "
@@ -298,7 +302,8 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
298
302
let cwd = FileManager . default. currentDirectoryPath
299
303
FileManager . default. changeCurrentDirectoryPath ( libArchivePath)
300
304
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
+
302
307
let swiftVerOutput = ( try await runProgramOutput ( swift, " --version " ) ) ?? " "
303
308
guard let swiftVerMatch = try swiftVerRegex. firstMatch ( in: swiftVerOutput) else {
304
309
throw Error ( message: " Unable to detect swift version " )
0 commit comments