Skip to content

Commit

Permalink
Update release flow (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Oct 13, 2023
1 parent 4258660 commit 72a93f3
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
4 changes: 4 additions & 0 deletions DemoApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>GOOGLE_CLIENT_ID</key>
<string>$(GOOGLE_CLIENT_ID)</string>
<key>REVERSED_GOOGLE_CLIENT_ID</key>
<string>$(REVERSED_GOOGLE_CLIENT_ID)</string>
</dict>
</plist>
13 changes: 11 additions & 2 deletions DemoApp/Sources/Components/AppEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@ extension AppEnvironment {

extension AppEnvironment {

enum InfoPlistValue: String {
case googleClientId = "GOOGLE_CLIENT_ID"
case googleReversedClientId = "REVERSED_GOOGLE_CLIENT_ID"
}

enum Argument: String {
case mockJWT = "MOCK_JWT"
}

enum Variable: String {
case JWTExpiration = "JWT_EXPIRATION"
case googleClientId = "GOOGLE_CLIENT_ID"
case googleReversedClientId = "REVERSED_GOOGLE_CLIENT_ID"
}

static func contains(_ argument: Argument) -> Bool {
Expand All @@ -127,6 +130,12 @@ extension AppEnvironment {
.processInfo
.environment[variable.rawValue]
}

static func value<T>(for variable: InfoPlistValue) -> T? {
Bundle
.main
.infoDictionary?[variable.rawValue] as? T
}
}

extension AppEnvironment {
Expand Down
2 changes: 1 addition & 1 deletion DemoApp/Sources/Views/Login/GoogleHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum GoogleHelper {
static func signIn() async throws -> UserCredentials {
guard
let rootViewController = UIApplication.shared.windows.first?.rootViewController,
let clientId = AppEnvironment.value(for: .googleClientId)
let clientId: String = AppEnvironment.value(for: .googleClientId)
else {
throw ClientError.Unexpected("No view controller available")
}
Expand Down
18 changes: 14 additions & 4 deletions DemoApp/Sources/Views/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ struct LoginView: View {
Image(systemName: "person.crop.circle.badge.clock.fill")
}

if
AppEnvironment.value(for: .googleClientId)?.isEmpty == false,
AppEnvironment.value(for: .googleReversedClientId)?.isEmpty == false
{
if isGoogleSignInAvailable {
LoginItemView {
Task {
let credentials = try await GoogleHelper.signIn()
Expand Down Expand Up @@ -102,6 +99,19 @@ struct LoginView: View {
}
}
}

private var isGoogleSignInAvailable: Bool {
guard
let clientId: String = AppEnvironment.value(for: .googleClientId),
let reversedClientId: String = AppEnvironment.value(for: .googleReversedClientId),
!clientId.isEmpty,
!reversedClientId.isEmpty
else{
return false
}

return true
}
}

struct LoginItemView<Title: View, Icon: View>: View {
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ GEM
bundler
fastlane
pry
fastlane-plugin-stream_actions (0.3.22)
fastlane-plugin-stream_actions (0.3.23)
xctest_list (= 1.2.1)
fastlane-plugin-versioning (0.5.2)
ffi (1.16.2)
Expand Down Expand Up @@ -411,7 +411,7 @@ DEPENDENCIES
fastlane
fastlane-plugin-emerge
fastlane-plugin-lizard
fastlane-plugin-stream_actions (= 0.3.22)
fastlane-plugin-stream_actions (= 0.3.23)
fastlane-plugin-versioning
jazzy
json
Expand Down
27 changes: 19 additions & 8 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,28 @@ lane :match_me do |options|
)
end

private_lane :update_google_plist do |options|
next if gci.nil?

Dir.glob(File.join("../#{options[:app_target]}", '**', '*.plist')).each do |plist_file|
old_content = File.read(plist_file)
new_content = old_content.gsub('$(GOOGLE_CLIENT_ID)', gci).gsub('$(REVERSED_GOOGLE_CLIENT_ID)', reversed_gci)
File.write(plist_file, new_content)
end
end

lane :swiftui_testflight_build do |options|
beta = options[:configuration] == 'Debug'
badge(path: 'DemoApp/') if beta
xcargs = beta ? "GOOGLE_CLIENT_ID='#{gci}' REVERSED_GOOGLE_CLIENT_ID='#{reversed_gci}'" : nil
app_target = 'DemoApp'

if options[:configuration] == 'Debug'
badge(path: app_target)
update_google_plist(app_target: app_target)
end

upload_beta(
app_target: 'DemoApp',
app_target: app_target,
app_identifier: 'io.getstream.iOS.VideoDemoApp',
configuration: options[:configuration],
xcargs: xcargs
configuration: options[:configuration]
)
end

Expand All @@ -113,8 +125,7 @@ private_lane :upload_beta do |options|
app_target: options[:app_target],
app_identifier: options[:app_identifier],
configuration: options[:configuration] || 'Release',
extensions: ['CallIntent', 'ScreenSharing'],
xcargs: options[:xcargs]
extensions: ['CallIntent', 'ScreenSharing']
)
end

Expand Down
2 changes: 1 addition & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gem 'fastlane-plugin-versioning'
gem 'fastlane-plugin-emerge'
gem 'fastlane-plugin-stream_actions', '0.3.22'
gem 'fastlane-plugin-stream_actions', '0.3.23'

0 comments on commit 72a93f3

Please sign in to comment.