createRelease function

Future<void> createRelease({
  1. required String username,
  2. required String apiToken,
  3. required String owner,
  4. required String repository,
})

Implementation

Future<void> createRelease(
    {required String username,
    required String apiToken,
    required String owner,
    required String repository}) async {
  final sgh = SimpleGitHub(
      username: username,
      apiToken: apiToken,
      owner: owner,
      repository: repository)
    ..auth();

  final pubspecPath = findPubSpec(startingDir: pwd);

  if (pubspecPath == null) {
    print('Unable to find pubspec.yaml, run ${DartScript.self.exeName} '
        'from the main '
        "package's root directory.");
    io.exit(1);
  }

  final pubspec = PubSpec.loadFromPath(pubspecPath);
  final version = pubspec.version.toString();
  final tagName = version;

  print('Creating release for $tagName');
  await _createRelease(sgh: sgh, pubspec: pubspec, tagName: tagName);

  await updateLatestTag(sgh: sgh, pubspec: pubspec);

  sgh.dispose();
}