diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b37ad3..c982858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 4d65709..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`). | diff --git a/action.yml b/action.yml index 7a48838..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 @@ -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}} diff --git a/lib/tag.dart b/lib/tag.dart index be94bb1..f7fe3c7 100644 --- a/lib/tag.dart +++ b/lib/tag.dart @@ -55,6 +55,10 @@ Future main(List? args) async { abbr: 't', defaultsTo: Platform.environment['GITHUB_TOKEN'], ); + parser.addOption( + 'branch', + defaultsTo: null, + ); final parsed = parser.parse(args ?? []); final path = parsed['path']; @@ -65,6 +69,7 @@ Future main(List? 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()) { @@ -99,6 +104,7 @@ Future main(List? args) async { } final options = { + 'branch': branchName, 'changelog': useChangelog, 'dryRun': dryRun, 'major': useMajor, @@ -119,8 +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, 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( diff --git a/pubspec.yaml b/pubspec.yaml index a8b750a..49eaf6c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: