@@ -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:
@@ -184,15 +189,31 @@ class PublishCommand extends PackageLoopingCommand {
184189
185190 for (final String pubspecPath in changedPubspecs) {
186191 // Read the ci_config.yaml file
187- final File ciConfigFile = File (pubspecPath).parent.childFile ('ci_config.yaml' );
188- final String ciConfigContent = ciConfigFile.readAsStringSync ();
189- final Map <String , dynamic > ciConfig =
190- yaml.loadYaml (ciConfigContent) as Map <String , dynamic >;
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+ }
191213 // Skip the package if batch release flag is not set to match the ci_config.yaml
192- if (getBoolArg (_batchReleaseFlag) != ciConfig['release' ]['batch' ] )
193- {
214+ if (getBoolArg (_batchReleaseFlag) != isBatchReleasePackage) {
194215 continue ;
195- }
216+
196217 // git outputs a relativa, Posix-style path.
197218 final File pubspecFile = childFileWithSubcomponents (
198219 packagesDir.fileSystem.directory ((await gitDir).path),
0 commit comments