Skip to content

Commit

Permalink
fix: export vaultName on startBuildWithCertificateAndPasswordFromOneP…
Browse files Browse the repository at this point in the history
…assword
  • Loading branch information
vanlooverenkoen committed Dec 12, 2023
1 parent 0579123 commit 49503ad
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.10.1

# Fix:
- Export `valultName` for `startBuildWithCertificateAndPasswordFromOnePassword` on the `CiCdPlugin`

# 0.10.0

# Feat:
Expand Down
1 change: 1 addition & 0 deletions example/bin/example_config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ExampleConfig {
static final appleEmailAdress = 'your-apple-email-adress';
static final appleAppSpecificPassword = Secret('your-app-specific-password');
static const onePasswordUuid = 'your-1password-uuid';
static const onePasswordVaultName = 'Certificates';
static const keyChainName = 'ImpaktfullCliKeyChain';
static final globalKeyChainPassword = CliInputReader.readKeyChainPassword();
}
4 changes: 2 additions & 2 deletions example/bin/ic_op_cicdflow_ios_1password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:impaktfull_cli/impaktfull_cli.dart';
import 'example_config.dart';

Future<void> main(List<String> arguments) => ImpaktfullCli().run(
(cli) =>
cli.ciCdPlugin.startBuildWithCertificateAndPasswordFromOnePassword(
(cli) => cli.ciCdPlugin.startBuildWithCertificateAndPasswordFromOnePassword(
vaultName: ExampleConfig.onePasswordVaultName,
opUuid: ExampleConfig.onePasswordUuid,
keyChainName: ExampleConfig.keyChainName,
globalKeyChainPassword: ExampleConfig.globalKeyChainPassword,
Expand Down
25 changes: 11 additions & 14 deletions example/bin/ic_op_script.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ Future<void> main(List<String> arguments) => ImpaktfullCli().run(
final keyChainPlugin = cli.macOsKeyChainPlugin;
final keyChainName = ExampleConfig.keyChainName;
final opUuid = ExampleConfig.onePasswordUuid;
final globalKeyChainPasswordSecret =
ExampleConfig.globalKeyChainPassword;
ImpaktfullCliEnvironment.requiresInstalledTools(
[CliTool.onePasswordCli]);
final opVaultName = ExampleConfig.onePasswordUuid;
final globalKeyChainPasswordSecret = ExampleConfig.globalKeyChainPassword;
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,
vaultName: opVaultName,
);

await keyChainPlugin.createKeyChain(
keyChainName, globalKeyChainPasswordSecret);
await keyChainPlugin.unlockKeyChain(
keyChainName, globalKeyChainPasswordSecret);
await keyChainPlugin.addCertificateToKeyChain(
keyChainName, certFile, certPassword);
await keyChainPlugin.createKeyChain(keyChainName, globalKeyChainPasswordSecret);
await keyChainPlugin.unlockKeyChain(keyChainName, globalKeyChainPasswordSecret);
await keyChainPlugin.addCertificateToKeyChain(keyChainName, certFile, certPassword);

ImpaktfullCliLogger.debug('Execute build');
await Future.delayed(const Duration(seconds: 2));
Expand Down
20 changes: 8 additions & 12 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 Down Expand Up @@ -149,8 +148,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
await testflightPlugin.uploadToTestflightWithEmailPassword(
file: file,
email: testflightUploadConfig.credentials?.userName,
appSpecificPassword:
testflightUploadConfig.credentials?.appSpecificPassword,
appSpecificPassword: testflightUploadConfig.credentials?.appSpecificPassword,
type: testflightUploadConfig.type,
);
}
Expand All @@ -159,6 +157,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
Future<void> startBuildWithCertificateAndPasswordFromOnePassword({
required String opUuid,
required String keyChainName,
required String vaultName,
required Future<void> Function() onStartBuild,
Secret? rawServiceAccount,
Secret? globalKeyChainPassword,
Expand All @@ -171,6 +170,7 @@ class CiCdPlugin extends ImpaktfullPlugin {
rawServiceAccount: rawServiceAccount,
);
final certPassword = await onePasswordPlugin.getCertificatePassword(
vaultName: vaultName,
opUuid: opUuid,
rawServiceAccount: rawServiceAccount,
);
Expand All @@ -192,15 +192,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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:impaktfull_cli/src/core/util/logger/logger.dart';
import 'package:impaktfull_cli/src/integrations/testflight/model/testflight_credentials.dart';

class OnePasswordPlugin extends ImpaktfullCliPlugin {
String get serviceAccountEnvKey =>
ImpaktfullCliEnvironmentVariables.envKeyOnePasswordAccountToken;
String get serviceAccountEnvKey => ImpaktfullCliEnvironmentVariables.envKeyOnePasswordAccountToken;

const OnePasswordPlugin({
required super.processRunner,
Expand All @@ -34,10 +33,11 @@ class OnePasswordPlugin extends ImpaktfullCliPlugin {
Secret? rawServiceAccount,
}) async {
final exportFile = File(outputPath);
if (exportFile.existsSync()) {
ImpaktfullCliLogger.verbose('Deleting existing file: $outputPath');
exportFile.deleteSync();
if (!exportFile.existsSync()) {
exportFile.createSync(recursive: true);
}
ImpaktfullCliLogger.verbose('Deleting existing file: $outputPath');
exportFile.deleteSync(recursive: true);
await _executeOnePasswordCommand(
[
'op',
Expand All @@ -58,7 +58,7 @@ class OnePasswordPlugin extends ImpaktfullCliPlugin {

Future<Secret> getCertificatePassword({
required String opUuid,
String vaultName = 'Certificates',
required String vaultName,
String fieldName = 'password',
Secret? rawServiceAccount,
}) =>
Expand Down

0 comments on commit 49503ad

Please sign in to comment.