feat: embed git SHA in app build + fix zip structure
- pass git SHA to xcodebuild via GCC_PREPROCESSOR_DEFINITIONS - create BuildInfo.swift to expose build version and git commit - fix ditto --keepParent to zip Eleven.app at root level (not Contents)
2 files changed,
+24
−2
.github/workflows/build-apps.yml+4 −2ios/LChatMac/BuildInfo.swift+20 −0
diff --git a/.github/workflows/build-apps.yml b/.github/workflows/build-apps.yml| index 9a834d4..23e7db8 100644 |
| --- a/.github/workflows/build-apps.yml |
| +++ b/.github/workflows/build-apps.yml |
| @@ -32,12 +32,14 @@ jobs: |
| run: | |
| xcodebuild -project LChat.xcodeproj -scheme LChatMac \ |
| -destination 'generic/platform=macOS' \ |
| - -derivedDataPath build CODE_SIGNING_ALLOWED=NO build |
| + -derivedDataPath build CODE_SIGNING_ALLOWED=NO \ |
| + GCC_PREPROCESSOR_DEFINITIONS='GIT_SHA="${{ github.sha }}"' \ |
| + build |
| - name: Package app |
| run: | |
| cd ios/build/Build/Products/Debug |
| - ditto -c -k --sequesterRsrc Eleven.app Eleven.app.zip |
| + ditto -c -k --sequesterRsrc --keepParent Eleven.app Eleven.app.zip |
| ls -lh Eleven.app.zip |
| - name: Create release |
diff --git a/ios/LChatMac/BuildInfo.swift b/ios/LChatMac/BuildInfo.swift| new file mode 100644 |
| index 0000000..f5b4b95 |
| --- /dev/null |
| +++ b/ios/LChatMac/BuildInfo.swift |
| @@ -0,0 +1,20 @@ |
| +import Foundation |
| + |
| +struct BuildInfo { |
| + #if GIT_SHA |
| + static let gitSha = String(stringLiteral: GIT_SHA).prefix(7) |
| + #else |
| + static let gitSha = "unknown" |
| + #endif |
| + |
| + static let versionString: String = { |
| + let bundle = Bundle.main |
| + let version = bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0" |
| + let build = bundle.infoDictionary?["CFBundleVersion"] as? String ?? "1" |
| + return "\(version) (build \(build))" |
| + }() |
| + |
| + static let buildDescription: String { |
| + "Eleven \(versionString)\nGit: \(gitSha)" |
| + } |
| +} |