pushReleaseTag method

void pushReleaseTag(
  1. Version? version, {
  2. required bool autoAnswer,
})

Implementation

void pushReleaseTag(Version? version, {required bool autoAnswer}) {
  assert(_usingGit == true, 'Must be using git');
  final tagName = '$version';
  // Check if the tag already exists and offer to replace it if it does.
  if (tagExists(tagName)) {
    if (autoAnswer ||
        confirm(
            'The tag $tagName already exists. Do you want to replace it?')) {
      'git tag -d $tagName'.start(workingDirectory: pathToGitRoot);
      if (hasRemote) {
        'git push --follow-tags'.start(workingDirectory: pathToGitRoot);
      }
      print('');
    }
  }

  print('Creating git tag.');
  'git tag -a $tagName -m "released $tagName"'
      .start(workingDirectory: pathToGitRoot);
  if (hasRemote) {
    'git push origin :refs/tags/$tagName'
        .start(workingDirectory: pathToGitRoot);
    'git push --follow-tags'.start(workingDirectory: pathToGitRoot);
  }
}