Skip to content

Commit

Permalink
fixed for unblocked runner
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane committed Sep 5, 2024
1 parent a6f240e commit 0bed1ec
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 52 deletions.
35 changes: 22 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"originHash" : "e5a8a0c5504f820e0bf8dbbd92ac72ff05ef8f1a3d78f18b21a465ed1b9d1fe2",
"originHash" : "5a938c80f27c8d18561c288f35b8b63fb0cfe0442d511438e468d8336acec67d",
"pins" : [
{
"identity" : "chaosbytestreams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/ChaosByteStreams",
"state" : {
"revision" : "67dadbb9f94a2407a765e2eb6294fa22ac3fa736",
"version" : "1.0.1"
"revision" : "f8e1ae4bd95760dd96e0b877d1672c98e9eb1486",
"version" : "1.0.2"
}
},
{
"identity" : "coercion",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Coercion.git",
"state" : {
"revision" : "f5ae9b7b191d9c042047e08e880e80ce676de230",
"version" : "1.1.2"
"revision" : "df699ebd4707bcfd99fcad4b9f6c09ddc1208af9",
"version" : "1.1.3"
}
},
{
"identity" : "files",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Files.git",
"state" : {
"revision" : "a86af44d44917e05facab8abb15a482383bd8f12",
"version" : "1.2.0"
"revision" : "ccb417b5b4f2d473964594a7c906a50a62c8530c",
"version" : "1.2.2"
}
},
{
Expand All @@ -37,13 +37,22 @@
"revision" : "f167c34fc0727a704cc871bef0867fc83b360d28"
}
},
{
"identity" : "matchable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Matchable.git",
"state" : {
"revision" : "d53e807009960aafbd54f6229c2542f906628b38",
"version" : "1.0.7"
}
},
{
"identity" : "runner",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Runner.git",
"state" : {
"revision" : "8034c25c136733d25da0c10f1ff27f1cecd1ab7a",
"version" : "2.0.10"
"revision" : "c192968875db172d1560e53a3084dc8b04ef5f1c",
"version" : "2.1.0"
}
},
{
Expand All @@ -60,17 +69,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Versionator.git",
"state" : {
"revision" : "6d1cdddce7990f660c4f3b96c5a24be8dcce9007",
"version" : "2.0.2"
"revision" : "00c24b0749348dc0692fab66eac9be5f55dbee3e",
"version" : "2.0.3"
}
},
{
"identity" : "xctestextensions",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/XCTestExtensions.git",
"state" : {
"revision" : "d57bdae3d001084247cd7cad771326cf710c3cc5",
"version" : "1.3.0"
"revision" : "40da6a09823c8a9bfa68b6487e92d86b8e8a821e",
"version" : "1.5.1"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ let package = Package(
.package(url: "https://github.com/elegantchaos/Coercion.git", from: "1.1.2"),
.package(url: "https://github.com/elegantchaos/Files.git", from: "1.2.0"),
.package(url: "https://github.com/elegantchaos/Logger.git", branch: "v2-wip"),
.package(url: "https://github.com/elegantchaos/Runner.git", from: "2.0.10"),
.package(url: "https://github.com/elegantchaos/Runner.git", from: "2.1.0"),
.package(url: "https://github.com/elegantchaos/ChaosByteStreams", from: "1.0.0"),
.package(url: "https://github.com/elegantchaos/Versionator.git", from: "2.0.2"),
.package(url: "https://github.com/elegantchaos/Versionator.git", from: "2.0.3"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
],

Expand Down
8 changes: 4 additions & 4 deletions Sources/ReleaseTools/Commands/AppcastCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct AppcastCommand: AsyncParsableCommand {
let fm = FileManager.default
let rootURL = URL(fileURLWithPath: fm.currentDirectoryPath)
let buildURL = rootURL.appendingPathComponent(".build")
let result = try xcode.run([
let result = xcode.run([
"build", "-workspace", parsed.workspace, "-scheme", "generate_appcast",
"BUILD_DIR=\(buildURL.path)",
])
Expand All @@ -82,7 +82,7 @@ struct AppcastCommand: AsyncParsableCommand {
let keyName = "\(workspaceName) Sparkle Key"

let generator = Runner(for: URL(fileURLWithPath: ".build/Release/generate_appcast"))
let genResult = try generator.run(["-n", keyName, "-k", keyChainPath, updates.path])
let genResult = generator.run(["-n", keyName, "-k", keyChainPath, updates.path])

try await genResult.throwIfFailed(!(await String(genResult.stdout)).contains("Unable to load DSA private key") ? AppcastError.appcastGeneratorFailed : nil)

Expand All @@ -97,13 +97,13 @@ struct AppcastCommand: AsyncParsableCommand {
parsed.log("Could not find Sparkle key - generating one.")

let keygen = Runner(for: URL(fileURLWithPath: "Dependencies/Sparkle/bin/generate_keys"))
let keygenResult = try keygen.run([])
let keygenResult = keygen.run([])
try await keygenResult.throwIfFailed(AppcastError.keyGenerationFailed)

parsed.log("Importing Key.")

let security = Runner(for: URL(fileURLWithPath: "/usr/bin/security"))
let importResult = try security.run([
let importResult = security.run([
"import", "dsa_priv.pem", "-a", "labl", "\(parsed.scheme) Sparkle Key",
])
try await importResult.throwIfFailed(AppcastError.keyImportFailed)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Commands/ArchiveCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct ArchiveCommand: AsyncParsableCommand {
break
}

let result = try xcode.run(args)
let result = xcode.run(args)
try await result.throwIfFailed(ArchiveError.archiveFailed)
parsed.log("Archived scheme \(parsed.scheme).")
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Commands/ChangesCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum ChangesError: Error {

public var description: String {
switch self {
case .couldntFetchLog(let error): return "Couldn't fetch the git log.\n\(error)"
case .couldntFetchLog(let error): return "Couldn't fetch the git log.\n\(error)"
}
}
}
Expand Down Expand Up @@ -47,7 +47,7 @@ struct ChangesCommand: AsyncParsableCommand {
}

do {
let result = try git.run(arguments)
let result = git.run(arguments)
let output = await String(result.stdout)
try output.write(to: parsed.changesURL, atomically: true, encoding: .utf8)
NSWorkspace.shared.open(parsed.changesURL)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Commands/CompressCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct CompressCommand: AsyncParsableCommand {
let ditto = DittoRunner(parsed: parsed)
let destination = updates.url.appendingPathComponent(parsed.archive.versionedZipName)

let result = try ditto.zip(stapledAppURL, as: destination)
let result = ditto.zip(stapledAppURL, as: destination)
try await result.throwIfFailed(CompressError.compressFailed)

parsed.log(
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Commands/ExportCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ExportCommand: AsyncParsableCommand {
parsed.log("Exporting \(parsed.scheme).")
let xcode = XCodeBuildRunner(parsed: parsed)
try? FileManager.default.removeItem(at: parsed.exportURL)
let result = try xcode.run([
let result = xcode.run([
"-exportArchive", "-archivePath", parsed.archiveURL.path, "-exportPath",
parsed.exportURL.path, "-exportOptionsPlist", parsed.exportOptionsURL.path,
"-allowProvisioningUpdates",
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Commands/NotarizeCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ struct NotarizeCommand: AsyncParsableCommand {
parsed.log("Creating archive for notarization.")
let ditto = DittoRunner(parsed: parsed)

let zipResult = try ditto.zip(parsed.exportedAppURL, as: parsed.exportedZipURL)
let zipResult = ditto.zip(parsed.exportedAppURL, as: parsed.exportedZipURL)
try await zipResult.throwIfFailed(NotarizeRunnerError.compressingFailed)

parsed.log("Uploading \(parsed.versionTag) to notarization service.")
let xcrun = XCRunRunner(parsed: parsed)
let result = try xcrun.run([
let result = xcrun.run([
"altool", "--notarize-app", "--primary-bundle-id", parsed.archive.identifier, "--username",
parsed.user, "--password", "@keychain:AC_PASSWORD", "--team-id", parsed.archive.team,
"--file", parsed.exportedZipURL.path, "--output-format", "xml",
Expand Down
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Commands/PublishCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ struct PublishCommand: AsyncParsableCommand {
git.cwd = website.websiteURL

parsed.log("Committing updates.")
var result = try git.run(["add", updates.path])
var result = git.run(["add", updates.path])
try await result.throwIfFailed(PublishError.commitFailed)

let message = "v\(parsed.archive.version), build \(parsed.archive.build)"
result = try git.run(["commit", "-a", "-m", message])
result = git.run(["commit", "-a", "-m", message])
try await result.throwIfFailed(PublishError.commitFailed)

parsed.log("Pushing updates.")
let pushResult = try git.run(["push"])
let pushResult = git.run(["push"])
try await pushResult.throwIfFailed(PublishError.pushFailed)
}
}
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Commands/UpdateBuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ struct UpdateBuildCommand: AsyncParsableCommand {
git.cwd = url
chdir(url.path)

var result = try git.run(["rev-list", "--count", "HEAD"])
var result = git.run(["rev-list", "--count", "HEAD"])
try await result.throwIfFailed(UpdateBuildError.gettingBuildFailed)

let build = await String(result.stdout).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)

result = try git.run(["rev-list", "--max-count", "1", "HEAD"])
result = git.run(["rev-list", "--max-count", "1", "HEAD"])
try await result.throwIfFailed(UpdateBuildError.gettingCommitFailed)
let commit = await String(result.stdout).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)

Expand Down Expand Up @@ -144,7 +144,7 @@ struct UpdateBuildCommand: AsyncParsableCommand {
throw UpdateBuildError.writingConfigFailed
}

let result = try git.run(["update-index", "--assume-unchanged", configURL.path])
let result = git.run(["update-index", "--assume-unchanged", configURL.path])
try await result.throwIfFailed(UpdateBuildError.updatingIndexFailed)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Commands/UploadCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ struct UploadCommand: AsyncParsableCommand {
let uploadResult: Runner.Session
if parsed.apiKey.isEmpty {
// use username & password
uploadResult = try xcrun.run([
uploadResult = xcrun.run([
"altool", "--upload-app", "--username", parsed.user, "--password", "@keychain:AC_PASSWORD",
"--file", parsed.exportedIPAURL.path, "--output-format", "xml", "--type", parsed.platform,
])
} else {
// use api key and issuer
uploadResult = try xcrun.run([
uploadResult = xcrun.run([
"altool", "--upload-app", "--apiIssuer", parsed.apiIssuer, "--apiKey", parsed.apiKey,
"--file", parsed.exportedIPAURL.path, "--output-format", "xml", "--type", parsed.platform,
])
Expand All @@ -89,7 +89,7 @@ struct UploadCommand: AsyncParsableCommand {

parsed.log("Tagging.")
let git = GitRunner()
let tagResult = try git.run([
let tagResult = git.run([
"tag", parsed.versionTag, "-m", "Uploaded with \(CommandLine.name)",
])
try await tagResult.throwIfFailed(GeneralError.taggingFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct WaitForNotarizationCommand: AsyncParsableCommand {

parsed.log("Tagging.")
let git = GitRunner()
let tagResult = try git.run([
let tagResult = git.run([
"tag", parsed.versionTag, "-f", "-m", "Uploaded with \(CommandLine.name)",
])
try await tagResult.throwIfFailed(GeneralError.taggingFailed)
Expand Down Expand Up @@ -119,7 +119,7 @@ struct WaitForNotarizationCommand: AsyncParsableCommand {
try? fm.removeItem(at: stapledAppURL)
try? fm.copyItem(at: parsed.exportedAppURL, to: stapledAppURL)
let xcrun = XCRunRunner(parsed: parsed)
let result = try xcrun.run(["stapler", "staple", stapledAppURL.path])
let result = xcrun.run(["stapler", "staple", stapledAppURL.path])
try await result.throwIfFailed(WaitForNotarizationRunnerError.exportingNotarizedAppFailed)
} else {
throw WaitForNotarizationError.missingArchive
Expand All @@ -131,14 +131,14 @@ struct WaitForNotarizationCommand: AsyncParsableCommand {

func check(request: String, parsed: OptionParser) async throws -> Bool {
let xcrun = XCRunRunner(parsed: parsed)
let result = try xcrun.run([
let result = xcrun.run([
"altool", "--notarization-info", request, "--username", parsed.user, "--password",
"@keychain:AC_PASSWORD", "--output-format", "xml",
])
try await result.throwIfFailed(WaitForNotarizationRunnerError.fetchingNotarizationStatusFailed)

parsed.log("Received response.")
let data = await Data(result.stdout)
let data = await Data(await result.stdout)
if let receipt = try? PropertyListSerialization.propertyList(
from: data, options: [], format: nil) as? [String: Any],
let info = receipt["notarization-info"] as? [String: Any],
Expand Down
10 changes: 5 additions & 5 deletions Sources/ReleaseTools/Runners/DittoRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class DittoRunner: Runner {
super.init(command: "ditto")
}

func run(_ arguments: [String]) throws -> Session {
func run(_ arguments: [String]) -> Session {
if parsed.showOutput {
parsed.log("ditto " + arguments.joined(separator: " "))
}

let mode = parsed.showOutput ? Runner.Mode.both : Runner.Mode.capture
return try run(arguments, stdoutMode: mode, stderrMode: mode)
let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}

func zip(_ url: URL, as zipURL: URL) throws -> Session {
func zip(_ url: URL, as zipURL: URL) -> Session {
parsed.log("Compressing \(url.lastPathComponent) to \(zipURL.path).")
return try run(["-c", "-k", "--sequesterRsrc", "--keepParent", url.path, zipURL.path])
return run(["-c", "-k", "--sequesterRsrc", "--keepParent", url.path, zipURL.path])
}
}
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Runners/XCRunRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class XCRunRunner: Runner {
super.init(command: "xcrun")
}

func run(_ arguments: [String]) throws -> Session {
func run(_ arguments: [String]) -> Session {
if parsed.showOutput {
parsed.log("xcrun " + arguments.joined(separator: " "))
}

let mode: Runner.Mode = parsed.showOutput ? .both : .capture
return try run(arguments, stdoutMode: mode, stderrMode: mode)
let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}
}
10 changes: 5 additions & 5 deletions Sources/ReleaseTools/Runners/XCodeBuildRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ class XCodeBuildRunner: Runner {
}

func schemes(workspace: String) async throws -> [String] {
let result = try run(["-workspace", workspace, "-list", "-json"])
let result = run(["-workspace", workspace, "-list", "-json"])
let output = await Data(result.stdout)
for await state in result.state {
if state == .succeeded {
let decoder = JSONDecoder()
let schemes = try decoder.decode(SchemesSpec.self, from: output)
return schemes.workspace.schemes
} else {
print(result.stderr)
print(await result.stderr)
}
}

return []
}

func run(_ arguments: [String]) throws -> Session {
func run(_ arguments: [String]) -> Session {
if parsed.showOutput {
parsed.log("\n> xcodebuild \(arguments.joined(separator: " "))\n")
}

let mode: Runner.Mode = parsed.showOutput ? .both : .capture
return try run(arguments, stdoutMode: mode, stderrMode: mode)
let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}
}

0 comments on commit 0bed1ec

Please sign in to comment.