From 079cd18d89191870472391f63de151009f9dc087 Mon Sep 17 00:00:00 2001 From: Diego Garcia Date: Tue, 24 Sep 2024 14:52:03 -0600 Subject: [PATCH] chore: address feedback --- README.md | 2 +- action.yml | 8 ++++---- lib/tag.dart | 11 ++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 65fb71a..57c8f7f 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ jobs: | Input | Description | |--------------|-------------------------------------------------------------------------------| +| `branch` | The target branch from which the tag will be created. | | `changelog` | Set to `false` to ignore the changelog description (default `true`). | | `major` | Set to `false` to prevent creating / updating the major tag (default `true`). | | `minor` | Set to `false` to prevent creating / updating the minor tag (default `true`). | @@ -140,4 +141,3 @@ jobs: | `path` | The path to the pubspec file to track (default: `.`). | | `prefix` | The prefix to place before the version number in the tag (default: `v`). | | `token` | The GitHub access token to create tags in the repository. | -| `branch` | The target branch from which the tag will be created. | diff --git a/action.yml b/action.yml index c32e4db..4a6ea06 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,9 @@ name: 'Auto Tag Dart Versions' description: 'Automatically create tags when you update your pubspec.yaml version' author: 'jpeiffer' inputs: + branch: + description: 'The target branch from which the tag will be created.' + required: false changelog: description: 'Set to false to skip scanning the changelog to apply the message.' required: false @@ -29,9 +32,6 @@ inputs: token: description: 'The GitHub access token to allow file reading and tag creation.' required: true - branch: - description: 'The target branch from which the tag will be created.' - required: false runs: using: 'composite' @@ -48,4 +48,4 @@ runs: set -e dart pub global activate -sgit https://github.com/peiffer-innovations/actions-dart-version-autotag - dart pub global run dart_version_autotag:tag --token ${{ inputs.token }} --path ${{ inputs.path }} --prefix "${{ inputs.prefix }}" --repository ${{ github.repository }} --changelog ${{inputs.changelog}} --major ${{inputs.major}} --minor ${{inputs.minor}} --overwrite ${{inputs.overwrite}} --branch ${{inputs.branch}} + dart pub global run dart_version_autotag:tag --token ${{ inputs.token }} --path ${{ inputs.path }} --prefix "${{ inputs.prefix }}" --repository ${{ github.repository }} --changelog ${{inputs.changelog}} --branch "${{inputs.branch}}" --major ${{inputs.major}} --minor ${{inputs.minor}} --overwrite ${{inputs.overwrite}} diff --git a/lib/tag.dart b/lib/tag.dart index 7a95d9f..f7fe3c7 100644 --- a/lib/tag.dart +++ b/lib/tag.dart @@ -69,7 +69,7 @@ Future main(List? args) async { final dryRun = parsed['dry-run'] == true; final overwrite = parsed['overwrite']?.toString().toLowerCase() == 'true'; final prefix = parsed['prefix']; - final branchName = parsed['branch'] as String?; + var branchName = parsed['branch'] as String? ?? ''; final pubspec = File('$path/pubspec.yaml'); if (!pubspec.existsSync()) { @@ -104,6 +104,7 @@ Future main(List? args) async { } final options = { + 'branch': branchName, 'changelog': useChangelog, 'dryRun': dryRun, 'major': useMajor, @@ -113,7 +114,6 @@ Future main(List? args) async { 'prefix': prefix, 'slug': slug, 'version': version, - if (branchName != null) 'branch': branchName, }; _logger.info('Options:'); for (var entry in options.entries) { @@ -125,11 +125,8 @@ Future main(List? args) async { final tags = await gh.repositories.listTags(slug).toList(); final repo = await gh.repositories.getRepository(slug); - - final branch = await gh.repositories.getBranch( - slug, - branchName ?? repo.defaultBranch, - ); + branchName = branchName.isNotEmpty ? branchName : repo.defaultBranch; + final branch = await gh.repositories.getBranch(slug, branchName); final sha = branch.commit!.sha!; final tagCreated = await _createTag(