Skip to content

Commit

Permalink
feat: better testflight config
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Dec 11, 2023
1 parent ed3f297 commit d81aedc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.6.0

# Feat:
- Better config for testflight upload

# 0.5.1 - 0.5.3

# Fix:
Expand Down
29 changes: 11 additions & 18 deletions lib/src/integrations/ci_cd/plugin/ci_cd_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
if (playStoreUploadConfig != null) {
await playStorePlugin.uploadToPlayStore(
file: file,
serviceAccountCredentialsFile:
playStoreUploadConfig.serviceAccountCredentialsFile,
serviceAccountCredentialsFile: playStoreUploadConfig.serviceAccountCredentialsFile,
);
}
}
Expand All @@ -100,7 +99,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
String? splitDebugInfoPaths = 'lib/main_',
int? buildNr,
AppCenterUploadConfig? appCenterUploadConfig,
TestflightUploadConfig? testflightUploadConfig,
TestFlightUploadConfig? testflightUploadConfig,
}) async =>
buildIos(
flavor: flavor,
Expand All @@ -120,7 +119,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
String? splitDebugInfoPath = '.build/debug-info',
int? buildNr,
AppCenterUploadConfig? appCenterUploadConfig,
TestflightUploadConfig? testflightUploadConfig,
TestFlightUploadConfig? testflightUploadConfig,
}) async {
ImpaktfullCliEnvironment.requiresInstalledTools([
CliTool.flutter,
Expand Down Expand Up @@ -148,8 +147,8 @@ class CiCdPlugin extends ImpaktfullPlugin {
if (testflightUploadConfig != null) {
await testflightPlugin.uploadToTestflightWithEmailPassword(
file: file,
email: testflightUploadConfig.userName,
appSpecificPassword: testflightUploadConfig.appSpecificPassword,
email: testflightUploadConfig.credentials?.userName,
appSpecificPassword: testflightUploadConfig.credentials?.appSpecificPassword,
type: testflightUploadConfig.type,
);
}
Expand All @@ -164,10 +163,8 @@ class CiCdPlugin extends ImpaktfullPlugin {
ImpaktfullCliEnvironment.requiresMacOs(reason: 'Building iOS/macOS apps');
ImpaktfullCliEnvironment.requiresInstalledTools([CliTool.onePasswordCli]);

final certFile =
await onePasswordPlugin.downloadDistributionCertificate(opUuid: opUuid);
final certPassword =
await onePasswordPlugin.getCertificatePassword(opUuid: opUuid);
final certFile = await onePasswordPlugin.downloadDistributionCertificate(opUuid: opUuid);
final certPassword = await onePasswordPlugin.getCertificatePassword(opUuid: opUuid);

await startBuildWithCertificateAndPassword(
keyChainName: keyChainName,
Expand All @@ -186,15 +183,11 @@ class CiCdPlugin extends ImpaktfullPlugin {
Secret? globalKeyChainPassword,
}) async {
ImpaktfullCliEnvironment.requiresMacOs(reason: 'Building iOS/macOS apps');
final globalKeyChainPasswordSecret = globalKeyChainPassword ??
ImpaktfullCliEnvironmentVariables.getUnlockKeyChainPassword();
final globalKeyChainPasswordSecret = globalKeyChainPassword ?? ImpaktfullCliEnvironmentVariables.getUnlockKeyChainPassword();

await macOsKeyChainPlugin.createKeyChain(
keyChainName, globalKeyChainPasswordSecret);
await macOsKeyChainPlugin.unlockKeyChain(
keyChainName, globalKeyChainPasswordSecret);
await macOsKeyChainPlugin.addCertificateToKeyChain(
keyChainName, certFile, certPassword);
await macOsKeyChainPlugin.createKeyChain(keyChainName, globalKeyChainPasswordSecret);
await macOsKeyChainPlugin.unlockKeyChain(keyChainName, globalKeyChainPasswordSecret);
await macOsKeyChainPlugin.addCertificateToKeyChain(keyChainName, certFile, certPassword);
await onStartBuild();
await macOsKeyChainPlugin.removeKeyChain(keyChainName);
}
Expand Down
33 changes: 21 additions & 12 deletions lib/src/integrations/one_password/plugin/one_password_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:impaktfull_cli/src/core/model/data/secret.dart';
import 'package:impaktfull_cli/src/core/plugin/impaktfull_cli_plugin.dart';
import 'package:impaktfull_cli/src/integrations/testflight/model/testflight_credentials.dart';

class OnePasswordPlugin extends ImpaktfullCliPlugin {
const OnePasswordPlugin({
Expand All @@ -13,14 +14,7 @@ class OnePasswordPlugin extends ImpaktfullCliPlugin {
String outputPath = 'certificates/apple_distribution.p12',
}) async {
final exportFile = File(outputPath);
await processRunner.runProcess([
'op',
'document',
'get',
'"$opUuid"',
'--out-file',
'"${exportFile.path}"'
]);
await processRunner.runProcess(['op', 'document', 'get', '"$opUuid"', '--out-file', '"${exportFile.path}"']);
return exportFile;
}

Expand All @@ -36,8 +30,7 @@ class OnePasswordPlugin extends ImpaktfullCliPlugin {
required String vaultName,
required String fieldName,
}) async {
final result = await getOnePasswordField(
vaultName: vaultName, opUuid: opUuid, fieldName: fieldName);
final result = await getOnePasswordField(vaultName: vaultName, opUuid: opUuid, fieldName: fieldName);
return Secret(result);
}

Expand All @@ -46,6 +39,22 @@ class OnePasswordPlugin extends ImpaktfullCliPlugin {
required String opUuid,
required String fieldName,
}) =>
processRunner
.runProcess(['op', 'read', 'op://$vaultName/$opUuid/$fieldName']);
processRunner.runProcess(['op', 'read', 'op://$vaultName/$opUuid/$fieldName']);

Future<TestFlightCredentials> getTestflightCredentials({
required String vaultName,
required String opUuid,
}) async =>
TestFlightCredentials(
userName: await getOnePasswordField(
vaultName: vaultName,
opUuid: opUuid,
fieldName: 'username',
),
appSpecificPassword: await getPassword(
vaultName: vaultName,
opUuid: opUuid,
fieldName: 'password',
),
);
}
16 changes: 16 additions & 0 deletions lib/src/integrations/testflight/model/testflight_credentials.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:impaktfull_cli/src/core/model/data/secret.dart';

class TestFlightCredentials {
/// username/email to login to appstoreconnect
/// defaults to env variable value of `APPLE_EMAIL`
final String? userName;

/// appSpecificPassword to login to appstoreconnect
/// defaults to env variable value of `APPLE_APP_SPECIFIC_PASSWORD`
final Secret? appSpecificPassword;

const TestFlightCredentials({
this.userName,
this.appSpecificPassword,
});
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import 'package:impaktfull_cli/src/core/model/data/secret.dart';
import 'package:impaktfull_cli/src/integrations/testflight/model/testflight_credentials.dart';

class TestflightUploadConfig {
/// username/email to login to appstoreconnect
/// defaults to env variable value of `APPLE_EMAIL`
final String? userName;

/// appSpecificPassword to login to appstoreconnect
/// defaults to env variable value of `APPLE_APP_SPECIFIC_PASSWORD`
final Secret? appSpecificPassword;
class TestFlightUploadConfig {
/// credentials to login to appstoreconnect
final TestFlightCredentials? credentials;

/// type of the app to upload
/// default: `ios`
final String type;

const TestflightUploadConfig({
this.userName,
this.appSpecificPassword,
const TestFlightUploadConfig({
this.credentials,
this.type = 'ios',
});
}

0 comments on commit d81aedc

Please sign in to comment.