pubRelease method
bool
pubRelease({
- required PubSpecDetails pubSpecDetails,
- required VersionMethod versionMethod,
- required int lineLength,
- required bool dryrun,
- required bool runTests,
- required bool autoAnswer,
- required String? tags,
- required String? excludeTags,
- required bool useGit,
- Version? setVersion,
Implementation
bool pubRelease({
required PubSpecDetails pubSpecDetails,
required VersionMethod versionMethod,
required int lineLength,
required bool dryrun,
required bool runTests,
required bool autoAnswer,
required String? tags,
required String? excludeTags,
required bool useGit,
Version? setVersion,
}) {
var success = false;
doRun(
dryrun: dryrun,
runRelease: () {
final projectRootPath = dirname(pubSpecDetails.path);
final newVersion = determineAndUpdateVersion(
versionMethod, setVersion, pubSpecDetails,
dryrun: dryrun);
runPubGet(projectRootPath);
if (runTests) {
if (!doRunTests(projectRootPath,
tags: tags, excludeTags: excludeTags)) {
throw UnitTestFailedException(
'Some unit tests failed. Release has been halted.');
}
}
final usingGit = useGit && gitChecks(projectRootPath);
runPreReleaseHooks(projectRootPath,
version: newVersion, dryrun: dryrun);
prepareReleaseNotes(
projectRootPath, newVersion, pubSpecDetails.pubspec.version,
usingGit: usingGit, autoAnswer: autoAnswer, dryrun: dryrun);
prepareCode(projectRootPath, lineLength, usingGit: usingGit);
commitRelease(newVersion, projectRootPath,
usingGit: usingGit, autoAnswer: autoAnswer, dryrun: dryrun);
// protect the pubspec.yaml as need to remove the
// overrides
withFileProtection([pubSpecDetails.path], () {
pubSpecDetails.removeOverrides();
success = publish(pubSpecDetails.path,
autoAnswer: autoAnswer, dryrun: dryrun);
});
runPostReleaseHooks(projectRootPath,
version: newVersion, dryrun: dryrun);
if (!success) {
printerr(red('The publish attempt failed.'));
}
});
return success;
}