Skip to content

Commit 82ae6d2

Browse files
authored
Merge pull request #15 from sidequery/nicosuave/bump-ghostrunk
Bump embedded worktrunk to 0.27.0 and auto-upgrade managed installs
2 parents 80b4363 + bda762d commit 82ae6d2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

macos/Sources/Features/Worktrunk/WorktrunkInstaller.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ enum WorktrunkInstallerError: LocalizedError {
3030

3131
enum WorktrunkInstaller {
3232
private struct Release {
33-
static let version = "0.22.0"
33+
static let version = "0.27.0"
3434
static let assetName = "worktrunk-aarch64-apple-darwin.tar.xz"
35-
static let sha256 = "1fd193d8ed95453dbeadd900035312a6df61ff3fad43dc85eb1a9f7b48895b3c"
35+
static let sha256 = "3ebfbe6b034afeb686bbddd39c0bee1942ed1448a7a7d5c9cca703ae9693683f"
3636

3737
static var url: URL {
3838
URL(string: "https://github.com/max-sixty/worktrunk/releases/download/v\(version)/\(assetName)")!
@@ -47,8 +47,11 @@ enum WorktrunkInstaller {
4747
let binDir = AgentStatusPaths.binDir
4848
let wtDest = binDir.appendingPathComponent("wt", isDirectory: false)
4949
let gitWtDest = binDir.appendingPathComponent("git-wt", isDirectory: false)
50+
let versionFile = binDir.appendingPathComponent(".worktrunk-version", isDirectory: false)
51+
5052
if FileManager.default.isExecutableFile(atPath: wtDest.path),
51-
FileManager.default.isExecutableFile(atPath: gitWtDest.path) {
53+
FileManager.default.isExecutableFile(atPath: gitWtDest.path),
54+
installedVersion(at: versionFile) == Release.version {
5255
return
5356
}
5457

@@ -96,6 +99,12 @@ enum WorktrunkInstaller {
9699
try makeExecutable(url: gitWtDest)
97100
_ = try? removeQuarantine(url: wtDest)
98101
_ = try? removeQuarantine(url: gitWtDest)
102+
103+
try? Release.version.write(to: versionFile, atomically: true, encoding: .utf8)
104+
}
105+
106+
private static func installedVersion(at url: URL) -> String? {
107+
try? String(contentsOf: url, encoding: .utf8).trimmingCharacters(in: .whitespacesAndNewlines)
99108
}
100109

101110
private static func isSupportedArchitecture() -> Bool {

0 commit comments

Comments
 (0)