mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Replace the readMarketingVersion method with a cleaner Yams based one and extract it into the shared tools
This commit is contained in:
committed by
Stefan Ceriu
parent
aa423e3592
commit
1d8639a11a
@@ -1,6 +1,7 @@
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import Subprocess
|
import Subprocess
|
||||||
|
import Yams
|
||||||
|
|
||||||
struct CI: ParsableCommand {
|
struct CI: ParsableCommand {
|
||||||
static let configuration = CommandConfiguration(abstract: "CI workflow commands that can be run both locally and in CI environments.",
|
static let configuration = CommandConfiguration(abstract: "CI workflow commands that can be run both locally and in CI environments.",
|
||||||
@@ -13,6 +14,19 @@ struct CI: ParsableCommand {
|
|||||||
|
|
||||||
static let testOutputDirectory = "test_output"
|
static let testOutputDirectory = "test_output"
|
||||||
|
|
||||||
|
/// Reads the `MARKETING_VERSION` from `project.yml`.
|
||||||
|
static func readMarketingVersion() throws -> String {
|
||||||
|
let projectURL = URL.projectDirectory.appending(component: "project.yml")
|
||||||
|
let projectString = try String(contentsOf: projectURL)
|
||||||
|
|
||||||
|
guard let projectConfig = try Yams.compose(yaml: projectString),
|
||||||
|
let version = projectConfig["settings"]?["MARKETING_VERSION"]?.string else {
|
||||||
|
throw ValidationError("Could not find MARKETING_VERSION in project.yml.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Linting
|
// MARK: - Linting
|
||||||
|
|
||||||
/// Runs SwiftFormat in lint mode against the current directory.
|
/// Runs SwiftFormat in lint mode against the current directory.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ struct ConfigureNightly: AsyncParsableCommand {
|
|||||||
try Zsh.run(command: "swift run pipeline update-foss-secrets")
|
try Zsh.run(command: "swift run pipeline update-foss-secrets")
|
||||||
try Zsh.run(command: "xcodegen")
|
try Zsh.run(command: "xcodegen")
|
||||||
|
|
||||||
let releaseVersion = try readMarketingVersion()
|
let releaseVersion = try CI.readMarketingVersion()
|
||||||
try await generateAppIconBanner(version: releaseVersion, buildNumber: buildNumber)
|
try await generateAppIconBanner(version: releaseVersion, buildNumber: buildNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,19 +41,6 @@ struct ConfigureNightly: AsyncParsableCommand {
|
|||||||
try updatedYAMLString.write(to: projectURL, atomically: true, encoding: .utf8)
|
try updatedYAMLString.write(to: projectURL, atomically: true, encoding: .utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads the MARKETING_VERSION from `project.yml`.
|
|
||||||
private func readMarketingVersion() throws -> String {
|
|
||||||
let projectURL = URL.projectDirectory.appending(component: "project.yml")
|
|
||||||
let projectString = try String(contentsOf: projectURL)
|
|
||||||
|
|
||||||
let marketingVersionRegex = /MARKETING_VERSION:\s*([^\s]+)/
|
|
||||||
guard let match = projectString.firstMatch(of: marketingVersionRegex) else {
|
|
||||||
throw ValidationError("Could not find MARKETING_VERSION in project.yml.")
|
|
||||||
}
|
|
||||||
|
|
||||||
return String(match.1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generates the app icon banner with version and build number.
|
/// Generates the app icon banner with version and build number.
|
||||||
private func generateAppIconBanner(version: String, buildNumber: String) async throws {
|
private func generateAppIconBanner(version: String, buildNumber: String) async throws {
|
||||||
let bannerText = "\(version) (\(buildNumber))"
|
let bannerText = "\(version) (\(buildNumber))"
|
||||||
|
|||||||
Reference in New Issue
Block a user