Skip to content

Commit

Permalink
Merge pull request #31 from diegog-sf/main
Browse files Browse the repository at this point in the history
Feat: Branch override for tag
  • Loading branch information
jpeiffer authored Sep 24, 2024
2 parents e658d78 + 079cd18 commit e5bd4e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.3.4] - September 24, 2024

* Ability to specify target branch to tag

## [2.3.3+5] - September 19, 2024

* Default message when changelog is set to false
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`). |
Expand Down
5 changes: 4 additions & 1 deletion 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 @@ -45,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}}
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}}
10 changes: 8 additions & 2 deletions lib/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Future<void> main(List<String>? args) async {
abbr: 't',
defaultsTo: Platform.environment['GITHUB_TOKEN'],
);
parser.addOption(
'branch',
defaultsTo: null,
);

final parsed = parser.parse(args ?? []);
final path = parsed['path'];
Expand All @@ -65,6 +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'];
var branchName = parsed['branch'] as String? ?? '';
final pubspec = File('$path/pubspec.yaml');

if (!pubspec.existsSync()) {
Expand Down Expand Up @@ -99,6 +104,7 @@ Future<void> main(List<String>? args) async {
}

final options = {
'branch': branchName,
'changelog': useChangelog,
'dryRun': dryRun,
'major': useMajor,
Expand All @@ -119,8 +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, 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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'dart_version_autotag'
description: 'A package that to scan the pubspec.yaml file and automatically create or update a tag in git for it.'
version: '2.3.3+5'
version: '2.3.4'
homepage: 'https://github.com/peiffer-innovations/actions-dart-version-autotag'

environment:
Expand Down

0 comments on commit e5bd4e0

Please sign in to comment.