Nightly display version (#670)

* Link to nightly and parse version better

* Add nightly date.
This commit is contained in:
Max Goedjen 2025-09-04 00:19:55 -07:00 committed by GitHub
parent e0c24917f2
commit 902d5c4a1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 46 additions and 12 deletions

View File

@ -30,7 +30,8 @@ jobs:
env: env:
RUN_ID: ${{ github.run_id }} RUN_ID: ${{ github.run_id }}
run: | run: |
sed -i '' -e "s/GITHUB_CI_VERSION/0.0.0/g" Sources/Config/Config.xcconfig DATE=$(date "+%Y-%m-%d")
sed -i '' -e "s/GITHUB_CI_VERSION/0.0.0_nightly-$DATE/g" Sources/Config/Config.xcconfig
sed -i '' -e "s/GITHUB_BUILD_NUMBER/1.$RUN_ID/g" Sources/Config/Config.xcconfig sed -i '' -e "s/GITHUB_BUILD_NUMBER/1.$RUN_ID/g" Sources/Config/Config.xcconfig
sed -i '' -e "s/GITHUB_BUILD_URL/https:\/\/github.com\/maxgoedjen\/secretive\/actions\/runs\/$RUN_ID/g" Sources/Secretive/Credits.rtf sed -i '' -e "s/GITHUB_BUILD_URL/https:\/\/github.com\/maxgoedjen\/secretive\/actions\/runs\/$RUN_ID/g" Sources/Secretive/Credits.rtf
- name: Build - name: Build

View File

@ -6292,6 +6292,17 @@
} }
} }
} }
},
"updater_download_latest_nightly_button" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Download Latest Nightly Build"
}
}
}
} }
}, },
"version" : "1.0" "version" : "1.0"

View File

@ -5,12 +5,20 @@ public struct SemVer: Sendable {
/// The SemVer broken into an array of integers. /// The SemVer broken into an array of integers.
let versionNumbers: [Int] let versionNumbers: [Int]
public let previewDescription: String?
public var isTestBuild: Bool {
versionNumbers == [0, 0, 0]
}
/// Initializes a SemVer from a string representation. /// Initializes a SemVer from a string representation.
/// - Parameter version: A string representation of the SemVer, formatted as "major.minor.patch". /// - Parameter version: A string representation of the SemVer, formatted as "major.minor.patch".
public init(_ version: String) { public init(_ version: String) {
// Betas have the format 1.2.3_beta1 // Betas have the format 1.2.3_beta1
let strippedBeta = version.split(separator: "_").first! // Nightlies have the format 0.0.0_nightly-2025-09-03
let splitFull = version.split(separator: "_")
let strippedBeta = splitFull.first!
previewDescription = splitFull.count > 1 ? String(splitFull[1]) : nil
var split = strippedBeta.split(separator: ".").compactMap { Int($0) } var split = strippedBeta.split(separator: ".").compactMap { Int($0) }
while split.count < 3 { while split.count < 3 {
split.append(0) split.append(0)
@ -22,6 +30,7 @@ public struct SemVer: Sendable {
/// - Parameter version: An `OperatingSystemVersion` representation of the SemVer. /// - Parameter version: An `OperatingSystemVersion` representation of the SemVer.
public init(_ version: OperatingSystemVersion) { public init(_ version: OperatingSystemVersion) {
versionNumbers = [version.majorVersion, version.minorVersion, version.patchVersion] versionNumbers = [version.majorVersion, version.minorVersion, version.patchVersion]
previewDescription = nil
} }
} }

View File

@ -13,12 +13,11 @@ import Observation
state.update state.update
} }
public let testBuild: Bool /// The current version of the app that is running.
public let currentVersion: SemVer
/// The current OS version. /// The current OS version.
private let osVersion: SemVer private let osVersion: SemVer
/// The current version of the app that is running.
private let currentVersion: SemVer
/// Initializes an Updater. /// Initializes an Updater.
/// - Parameters: /// - Parameters:
@ -34,7 +33,6 @@ import Observation
) { ) {
self.osVersion = osVersion self.osVersion = osVersion
self.currentVersion = currentVersion self.currentVersion = currentVersion
testBuild = currentVersion == SemVer("0.0.0")
if checkOnLaunch { if checkOnLaunch {
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet. // Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
Task { Task {

View File

@ -5,8 +5,8 @@ public protocol UpdaterProtocol: Observable, Sendable {
/// The latest update /// The latest update
@MainActor var update: Release? { get } @MainActor var update: Release? { get }
/// A boolean describing whether or not the current build of the app is a "test" build (ie, a debug build or otherwise special build)
var testBuild: Bool { get } var currentVersion: SemVer { get }
func ignore(release: Release) async func ignore(release: Release) async
} }

View File

@ -58,7 +58,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
updater.update updater.update
} onChange: { [updater, notifier] in } onChange: { [updater, notifier] in
Task { Task {
guard !updater.testBuild else { return } guard !updater.currentVersion.isTestBuild else { return }
await notifier.notify(update: updater.update!) { release in await notifier.notify(update: updater.update!) { release in
await updater.ignore(release: release) await updater.ignore(release: release)
} }

View File

@ -6,7 +6,7 @@ import Brief
var update: Release? = nil var update: Release? = nil
let testBuild = false let currentVersion = SemVer("0.0.0_preview")
init(update: Update = .none) { init(update: Update = .none) {
switch update { switch update {

View File

@ -75,7 +75,7 @@ extension ContentView {
if update.critical { if update.critical {
return (.updateCriticalNoticeTitle, .red) return (.updateCriticalNoticeTitle, .red)
} else { } else {
if updater.testBuild { if updater.currentVersion.isTestBuild {
return (.updateTestNoticeTitle, .blue) return (.updateTestNoticeTitle, .blue)
} else { } else {
return (.updateNormalNoticeTitle, .orange) return (.updateNormalNoticeTitle, .orange)
@ -95,10 +95,25 @@ extension ContentView {
}) })
.buttonStyle(ToolbarButtonStyle(color: color)) .buttonStyle(ToolbarButtonStyle(color: color))
.sheet(item: $selectedUpdate) { update in .sheet(item: $selectedUpdate) { update in
VStack {
if updater.currentVersion.isTestBuild {
VStack {
if let description = updater.currentVersion.previewDescription {
Text(description)
}
Link(destination: URL(string: "https://github.com/maxgoedjen/secretive/actions/workflows/nightly.yml")!) {
Button(.updaterDownloadLatestNightlyButton) {}
.frame(maxWidth: .infinity)
.primaryButton()
}
}
.padding()
}
UpdateDetailView(update: update) UpdateDetailView(update: update)
} }
} }
} }
}
@ViewBuilder @ViewBuilder
var newItemView: some View { var newItemView: some View {