@@ -78,6 +78,11 @@ class PublishCommand extends PackageLoopingCommand {
7878 'Release all packages that contains pubspec changes at the current commit compares to the base-sha.\n '
7979 'The --packages option is ignored if this is on.' ,
8080 );
81+ argParser.addFlag (
82+ _batchReleaseFlag,
83+ help:
84+ 'only release the packages that opt-in for batch release option.'
85+ )
8186 argParser.addFlag (
8287 _dryRunFlag,
8388 help:
@@ -99,6 +104,7 @@ class PublishCommand extends PackageLoopingCommand {
99104 static const String _pubFlagsOption = 'pub-publish-flags' ;
100105 static const String _remoteOption = 'remote' ;
101106 static const String _allChangedFlag = 'all-changed' ;
107+ static const String _batchReleaseFlag = 'batch-release' ;
102108 static const String _dryRunFlag = 'dry-run' ;
103109 static const String _skipConfirmationFlag = 'skip-confirmation' ;
104110 static const String _tagForAutoPublishFlag = 'tag-for-auto-publish' ;
@@ -182,6 +188,32 @@ class PublishCommand extends PackageLoopingCommand {
182188 .toList ();
183189
184190 for (final String pubspecPath in changedPubspecs) {
191+ // Read the ci_config.yaml file
192+
193+ final String packageName = p.basename (p.dirname (pubspecPath));
194+ bool isBatchReleasePackage;
195+ try {
196+ final File ciConfigFile = packagesDir.fileSystem
197+ .file (pubspecPath)
198+ .parent
199+ .childFile ('ci_config.yaml' );
200+ final YamlMap ? ciConfig =
201+ loadYaml (ciConfigFile.readAsStringSync ()) as YamlMap ? ;
202+ final dynamic batchValue = ciConfig? ['release' ]? ['batch' ];
203+ if (batchValue is ! bool ) {
204+ printError (
205+ '`release.batch` key is missing or not a boolean in ci_config.yaml for $packageName .' );
206+ continue ;
207+ }
208+ isBatchReleasePackage = batchValue;
209+ } catch (e) {
210+ printError ('Could not parse ci_config.yaml for $packageName : $e ' );
211+ continue ;
212+ }
213+ // Skip the package if batch release flag is not set to match the ci_config.yaml
214+ if (getBoolArg (_batchReleaseFlag) != isBatchReleasePackage) {
215+ continue ;
216+
185217 // git outputs a relativa, Posix-style path.
186218 final File pubspecFile = childFileWithSubcomponents (
187219 packagesDir.fileSystem.directory ((await gitDir).path),
0 commit comments