diff --git a/script/tool/lib/src/publish_plugin_command.dart b/script/tool/lib/src/publish_plugin_command.dart index 622a1a3cb133..18b6ff0ed742 100644 --- a/script/tool/lib/src/publish_plugin_command.dart +++ b/script/tool/lib/src/publish_plugin_command.dart @@ -290,6 +290,14 @@ Safe to ignore if the package is deleted in this commit. } final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + + if (pubspec.name == 'flutter_plugin_tools') { + // Ignore flutter_plugin_tools package when running publishing through flutter_plugin_tools. + // TODO(cyanglaz): Make the tool also auto publish flutter_plugin_tools package. + // https://github.com/flutter/flutter/issues/85430 + return _CheckNeedsReleaseResult.noRelease; + } + if (pubspec.publishTo == 'none') { return _CheckNeedsReleaseResult.noRelease; } diff --git a/script/tool/test/publish_plugin_command_test.dart b/script/tool/test/publish_plugin_command_test.dart index c7832e0da191..f060cd2fbfd8 100644 --- a/script/tool/test/publish_plugin_command_test.dart +++ b/script/tool/test/publish_plugin_command_test.dart @@ -995,6 +995,57 @@ void main() { ])); expect(processRunner.pushTagsArgs, isEmpty); }); + + test('Do not release flutter_plugin_tools', () async { + const Map httpResponsePlugin1 = { + 'name': 'flutter_plugin_tools', + 'versions': [], + }; + + final MockClient mockClient = MockClient((http.Request request) async { + if (request.url.pathSegments.last == 'flutter_plugin_tools.json') { + return http.Response(json.encode(httpResponsePlugin1), 200); + } + return http.Response('', 500); + }); + final PublishPluginCommand command = PublishPluginCommand(packagesDir, + processRunner: processRunner, + print: (Object? message) => printedMessages.add(message.toString()), + stdinput: mockStdin, + httpClient: mockClient, + gitDir: gitDir); + + commandRunner = CommandRunner( + 'publish_check_command', + 'Test for publish-check command.', + ); + commandRunner.addCommand(command); + + final Directory flutterPluginTools = + createFakePlugin('flutter_plugin_tools', packagesDir); + await gitDir.runCommand(['add', '-A']); + await gitDir.runCommand(['commit', '-m', 'Add plugins']); + // Immediately return 0 when running `pub publish`. + processRunner.mockPublishCompleteCode = 0; + mockStdin.readLineOutput = 'y'; + await commandRunner + .run(['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + expect( + printedMessages, + containsAllInOrder([ + 'Checking local repo...', + 'Local repo is ready!', + 'Done!' + ])); + expect( + printedMessages.contains( + 'Running `pub publish ` in ${flutterPluginTools.path}...\n', + ), + isFalse); + expect(processRunner.pushTagsArgs, isEmpty); + processRunner.pushTagsArgs.clear(); + printedMessages.clear(); + }); }); }