From 0ec336ba192122e38f7cab82d61036d2bd912d82 Mon Sep 17 00:00:00 2001 From: Sam Deane Date: Fri, 9 Aug 2024 17:29:23 +0100 Subject: [PATCH] No longer rely on config files - just inject the INFO_PLIST settings --- .swiftpm/configuration/Package.resolved | 88 +++++++++++++++++++ .../Commands/ArchiveCommand.swift | 4 +- .../Commands/BootstrapCommand.swift | 4 +- .../Commands/UpdateBuildCommand.swift | 5 +- Sources/ReleaseTools/meta.swift | 8 +- 5 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 .swiftpm/configuration/Package.resolved diff --git a/.swiftpm/configuration/Package.resolved b/.swiftpm/configuration/Package.resolved new file mode 100644 index 0000000..3aa93ea --- /dev/null +++ b/.swiftpm/configuration/Package.resolved @@ -0,0 +1,88 @@ +{ + "object": { + "pins": [ + { + "package": "Builder", + "repositoryURL": "https://github.com/elegantchaos/Builder.git", + "state": { + "branch": null, + "revision": "2c62722be9ed28035242a05f6abcc154a514ca9e", + "version": "1.2.3" + } + }, + { + "package": "BuilderConfiguration", + "repositoryURL": "https://github.com/elegantchaos/BuilderConfiguration.git", + "state": { + "branch": null, + "revision": "c21cebac262244d920894bba2351ff65c1378bf2", + "version": "1.1.5" + } + }, + { + "package": "Coercion", + "repositoryURL": "https://github.com/elegantchaos/Coercion.git", + "state": { + "branch": null, + "revision": "df699ebd4707bcfd99fcad4b9f6c09ddc1208af9", + "version": "1.1.3" + } + }, + { + "package": "Files", + "repositoryURL": "https://github.com/elegantchaos/Files.git", + "state": { + "branch": null, + "revision": "ccb417b5b4f2d473964594a7c906a50a62c8530c", + "version": "1.2.2" + } + }, + { + "package": "Logger", + "repositoryURL": "https://github.com/elegantchaos/Logger.git", + "state": { + "branch": null, + "revision": "a5cfb4ede43a0f4782afb2aea3175a04f206efcf", + "version": "1.8.1" + } + }, + { + "package": "Matchable", + "repositoryURL": "https://github.com/elegantchaos/Matchable.git", + "state": { + "branch": null, + "revision": "d53e807009960aafbd54f6229c2542f906628b38", + "version": "1.0.7" + } + }, + { + "package": "Runner", + "repositoryURL": "https://github.com/elegantchaos/Runner.git", + "state": { + "branch": null, + "revision": "65420eb4e534a58c8fb1bf18e344bc86edb42c65", + "version": "1.3.2" + } + }, + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "6b2aa2748a7881eebb9f84fb10c01293e15b52ca", + "version": "0.5.0" + } + }, + { + "package": "XCTestExtensions", + "repositoryURL": "https://github.com/elegantchaos/XCTestExtensions.git", + "state": { + "branch": null, + "revision": "39694671be8bea1ab0bbd87114705b2a92567a8e", + "version": "1.5.0" + } + } + ] + }, + "version": 1 +} diff --git a/Sources/ReleaseTools/Commands/ArchiveCommand.swift b/Sources/ReleaseTools/Commands/ArchiveCommand.swift index cacb6a6..6f6306e 100644 --- a/Sources/ReleaseTools/Commands/ArchiveCommand.swift +++ b/Sources/ReleaseTools/Commands/ArchiveCommand.swift @@ -52,11 +52,11 @@ struct ArchiveCommand: ParsableCommand { parsed.log("Updating Version Info") let infoHeaderPath = "\(parsed.buildURL.path)/VersionInfo.h" - try UpdateBuildCommand.generateHeader(parsed: parsed, header: infoHeaderPath, repo: parsed.rootURL.path) + let build = try UpdateBuildCommand.generateHeader(parsed: parsed, header: infoHeaderPath, repo: parsed.rootURL.path) parsed.log("Archiving scheme \(parsed.scheme).") let xcode = XCodeBuildRunner(parsed: parsed) - var args = ["-workspace", parsed.workspace, "-scheme", parsed.scheme, "archive", "-archivePath", parsed.archiveURL.path, "-allowProvisioningUpdates", "INFOPLIST_PREFIX_HEADER=\(infoHeaderPath)"] + var args = ["-workspace", parsed.workspace, "-scheme", parsed.scheme, "archive", "-archivePath", parsed.archiveURL.path, "-allowProvisioningUpdates", "INFOPLIST_PREFIX_HEADER=\(infoHeaderPath)", "INFOPLIST_PREPROCESS=YES", "CURRENT_PROJECT_VERSION=\(build)"] if let config = xcconfig { args.append(contentsOf: ["-xcconfig", config]) } diff --git a/Sources/ReleaseTools/Commands/BootstrapCommand.swift b/Sources/ReleaseTools/Commands/BootstrapCommand.swift index ba0a465..efe5457 100644 --- a/Sources/ReleaseTools/Commands/BootstrapCommand.swift +++ b/Sources/ReleaseTools/Commands/BootstrapCommand.swift @@ -37,8 +37,8 @@ struct BootstrapCommand: ParsableCommand { command: Self.configuration ) - parsed.log("Copying .xcconfig files to \(Self.localConfigFolder).") - try Resources.configsPath.merge(into: Self.localConfigFolder) +// parsed.log("Copying .xcconfig files to \(Self.localConfigFolder).") +// try Resources.configsPath.merge(into: Self.localConfigFolder) parsed.log("Copying scripts to \(Self.localScriptsFolder).") try Resources.scriptsPath.merge(into: Self.localScriptsFolder) diff --git a/Sources/ReleaseTools/Commands/UpdateBuildCommand.swift b/Sources/ReleaseTools/Commands/UpdateBuildCommand.swift index b9cdec3..73b8948 100644 --- a/Sources/ReleaseTools/Commands/UpdateBuildCommand.swift +++ b/Sources/ReleaseTools/Commands/UpdateBuildCommand.swift @@ -103,16 +103,17 @@ struct UpdateBuildCommand: ParsableCommand { } } - static func generateHeader(parsed: OptionParser, header: String, repo: String) throws { + static func generateHeader(parsed: OptionParser, header: String, repo: String) throws -> String { let headerURL = URL(fileURLWithPath: header) let repoURL = URL(fileURLWithPath: repo) let git = GitRunner() let (build, commit) = try getBuild(in: repoURL, using: git) parsed.log("Setting build number to \(build).") - let header = "#define BUILD \(build)\n#define COMMIT \(commit)" + let header = "#define BUILD \(build)\n#define CURRENT_PROJECT_VERSION \(build)\n#define COMMIT \(commit)" try? FileManager.default.createDirectory(at: headerURL.deletingLastPathComponent(), withIntermediateDirectories: true) try header.write(to: headerURL, atomically: true, encoding: .utf8) + return build } static func generateConfig(parsed: OptionParser, config: String?) throws { diff --git a/Sources/ReleaseTools/meta.swift b/Sources/ReleaseTools/meta.swift index 84bc6ee..44f684f 100644 --- a/Sources/ReleaseTools/meta.swift +++ b/Sources/ReleaseTools/meta.swift @@ -1,8 +1,8 @@ struct Metadata { - let build = "182" - let version = "v1.3.6" - let commit = "3a2ca6fcb7e926f704f136cc0b6f699bcdf1d28a" - let tags = "tags/v1.3.6" + let build = "184" + let version = "v1.3.6-2-g695ebe2" + let commit = "695ebe27d6992d8441df3551be341fd4d47b3bc7" + let tags = "heads/main" static var main = Metadata() }