From 0994bd145a641aa6491a03c43e2dd1ea0064426f Mon Sep 17 00:00:00 2001 From: Jamil Date: Thu, 22 Aug 2024 13:49:57 -0700 Subject: [PATCH] feat(apple): Build GITHUB_SHA into Apple clients (#6406) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #6401 Screenshot 2024-08-21 at 11 52 31 PM ![Screenshot 2024-08-22 at 12 05 44 AM](https://github.com/user-attachments/assets/5e1209f9-e8fa-4453-9bdd-9f40339649b4) --- .github/workflows/_swift.yml | 2 ++ swift/apple/Firezone/Info.plist | 2 ++ .../FirezoneKit/Helpers/AppInfoPlistConstants.swift | 8 ++++++++ .../Sources/FirezoneKit/Views/SettingsView.swift | 13 +++++++++++++ website/src/components/Changelog/Apple.tsx | 9 +++++++++ 5 files changed, 34 insertions(+) diff --git a/.github/workflows/_swift.yml b/.github/workflows/_swift.yml index 0c69598f2..657cd0dd5 100644 --- a/.github/workflows/_swift.yml +++ b/.github/workflows/_swift.yml @@ -113,6 +113,7 @@ jobs: if [ "${{ matrix.platform }}" = "iOS" ]; then # Build archive xcodebuild archive \ + GIT_SHA=${GITHUB_SHA} \ -skipMacroValidation \ -archivePath $RUNNER_TEMP/Firezone.xcarchive \ -configuration Release \ @@ -131,6 +132,7 @@ jobs: elif [ "${{ matrix.platform }}" = "macOS" ]; then # Build app bundle xcodebuild build \ + GIT_SHA=${GITHUB_SHA} \ -skipMacroValidation \ -configuration Release \ -scheme Firezone \ diff --git a/swift/apple/Firezone/Info.plist b/swift/apple/Firezone/Info.plist index a9ca532ad..92b464e8e 100644 --- a/swift/apple/Firezone/Info.plist +++ b/swift/apple/Firezone/Info.plist @@ -19,5 +19,7 @@ $(APP_GROUP_ID) ITSAppUsesNonExemptEncryption + GitSha + $(GIT_SHA) diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Helpers/AppInfoPlistConstants.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Helpers/AppInfoPlistConstants.swift index 07fec59e4..012603fd9 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Helpers/AppInfoPlistConstants.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Helpers/AppInfoPlistConstants.swift @@ -7,6 +7,14 @@ import Foundation struct AppInfoPlistConstants { + static var gitSha: String { + guard let gitSha = Bundle.main.object(forInfoDictionaryKey: "GitSha") as? String, + !gitSha.isEmpty + else { return "unknown" } + + return String(gitSha.prefix(8)) + } + static var appGroupId: String { guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: "AppGroupIdentifier") as? String else { diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/SettingsView.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/SettingsView.swift index 231d45488..a573853e2 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/SettingsView.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/SettingsView.swift @@ -365,6 +365,12 @@ public struct SettingsView: View { Spacer() } Spacer() + HStack { + Text("Build: \(AppInfoPlistConstants.gitSha)") + .textSelection(.enabled) + .foregroundColor(.gray) + Spacer() + }.padding([.leading, .bottom], 20) } #elseif os(iOS) VStack { @@ -432,6 +438,13 @@ public struct SettingsView: View { footer: { Text(FootnoteText.forAdvanced) } ) } + Spacer() + HStack { + Text("Build: \(AppInfoPlistConstants.gitSha)") + .textSelection(.enabled) + .foregroundColor(.gray) + Spacer() + }.padding([.leading, .bottom], 20) } #endif } diff --git a/website/src/components/Changelog/Apple.tsx b/website/src/components/Changelog/Apple.tsx index 4bf32eaf8..2dcef1b72 100644 --- a/website/src/components/Changelog/Apple.tsx +++ b/website/src/components/Changelog/Apple.tsx @@ -9,6 +9,15 @@ export default function Apple() { href="https://apps.apple.com/us/app/firezone/id6443661826" title="macOS / iOS" > + {/* + +
    + + Shows the Git SHA corresponding to the build on the Settings -> Advanced screen. + +
+
+ */}