runRelease method

Future<void> runRelease(
  1. String bumpType, {
  2. bool noCommit = false,
  3. bool noTag = false,
  4. bool push = false,
  5. bool noChangelog = false,
})

Implementation

Future<void> runRelease(
    String bumpType, {
      bool noCommit = false,
      bool noTag = false,
      bool push = false,
      bool noChangelog = false,
    }) async {
  if (!_isValidBumpType(bumpType)) {
    throw ArgumentError('Invalid bump type: $bumpType');
  }

  final nextVersion = await _calculateNextVersion(bumpType);

  await executor.updateVersion(nextVersion);

  // Tag only if commit is created
  final canTag = !noCommit && !noTag;

  if (!noCommit) {
    if (!noChangelog) {
      final changelog =
      await ChangelogGenerator(executor, now: _now).generate(nextVersion);

      await _appendToChangelog(changelog);
    }

    await executor.commit('chore: release $nextVersion');
  } else if (!noTag) {
    executor.getLogger.warn('[WARNING] Cannot generate changelog because commit was skipped.');
    executor.getLogger.warn('[WARNING] Cannot create tag because commit was skipped.');
  }

  if (canTag) {
    await executor.createTag('v$nextVersion');
  }

  if (!noCommit) {
    if (push) await executor.push();
  } else if (push) {
    executor.getLogger.warn('[WARNING] Cannot push because commit was skipped.');
  }
}