Skip to content

Commit

Permalink
chore: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
diegog-sf committed Sep 24, 2024
1 parent 9466c1a commit 079cd18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ 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`). |
| `overwrite` | Set to `false` to abort if the full version already exists (default `true`). |
| `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. |
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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}}
11 changes: 4 additions & 7 deletions lib/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Future<void> main(List<String>? 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()) {
Expand Down Expand Up @@ -104,6 +104,7 @@ Future<void> main(List<String>? args) async {
}

final options = {
'branch': branchName,
'changelog': useChangelog,
'dryRun': dryRun,
'major': useMajor,
Expand All @@ -113,7 +114,6 @@ Future<void> main(List<String>? args) async {
'prefix': prefix,
'slug': slug,
'version': version,
if (branchName != null) 'branch': branchName,
};
_logger.info('Options:');
for (var entry in options.entries) {
Expand All @@ -125,11 +125,8 @@ Future<void> main(List<String>? 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(
Expand Down

0 comments on commit 079cd18

Please sign in to comment.