doRun method
Implementation
@override
Future<int> doRun() async {
final args = argResults!;
final isDemo = args[_argDemo] as bool;
if (!isDemo) {
fs = const IOFileSystem();
} else {
printInfo("Demonstration mode");
fs = DemoFileSystem();
}
git = getGit(config, isDemo: isDemo);
final skipL10n = args[_argSkipL10n] as bool? ?? false;
final isLocalRelease = args[_argLocal] as bool? ?? false;
final ciConfig = config.ci;
if (!ciConfig.enabled && !isLocalRelease) {
return error(1,
message: 'You can only use local release if CI is disabled. '
'See --$_argLocal and section ci in alex config section.');
}
final targetPath = (args[_argTargetPath] as String?)?.trim();
if (targetPath != null) {
if (!isLocalRelease) {
return error(1,
message: 'Option --$_argTargetPath can be used '
'only for local release builds. See --$_argLocal.');
}
if (targetPath.isEmpty) {
return error(1, message: "Option --$_argTargetPath can't be empty.");
}
// Fail before the release is started if the target can't be used.
final targetDir = await _ensureTargetDir(targetPath);
_checkTargetDirIsNotInRepo(targetDir);
}
git.ensureCleanAndCheckoutDevelop();
final rollback = ReleaseRollback(
git,
info: printInfo,
warning: printWarning,
error: printError,
verbose: printVerbose,
);
// The working tree is clean at this point,
// so this state can be safely restored.
rollback.start();
try {
final res = await _release(
rollback: rollback,
skipL10n: skipL10n,
isLocalRelease: isLocalRelease,
targetPath: targetPath,
);
if (res != 0) {
rollback.run(reason: 'Release failed with exit code $res.');
}
return res;
// ignore: avoid_catches_without_on_clauses
} catch (e) {
rollback.run(reason: '$e');
rethrow;
}
}