Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: release
name: Reusable Release

on:
push:
branches:
- main
workflow_call:
inputs:
publish-args:
required: true
type: string
workflow-name:
required: true
type: string

# Declare default permissions as read only.
permissions: read-all
Expand Down Expand Up @@ -82,5 +88,5 @@ jobs:
run: |
git config --global user.name ${{ secrets.USER_NAME }}
git config --global user.email ${{ secrets.USER_EMAIL }}
dart ./script/tool/lib/src/main.dart publish --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin
dart ./script/tool/lib/src/main.dart publish ${{ inputs.publish-args }}
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}
12 changes: 12 additions & 0 deletions .github/workflows/release_from_batch_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Batch Release
on:
push:
branches:
- release
jobs:
release:
uses: ./.github/workflows/reusable_release.yml
with:
publish-args: '--all-changed --batch-release --base-sha=HEAD~ --skip-confirmation --remote=origin'
workflow-name: 'Batch Release'
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/release_from_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Main Release
on:
push:
branches:
- main
jobs:
release:
uses: ./.github/workflows/reusable_release.yml
with:
publish-args: '--all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin'
workflow-name: 'Main Release'
secrets: inherit
31 changes: 31 additions & 0 deletions script/tool/lib/src/publish_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class PublishCommand extends PackageLoopingCommand {
'Release all packages that contains pubspec changes at the current commit compares to the base-sha.\n'
'The --packages option is ignored if this is on.',
);
argParser.addFlag(_batchReleaseFlag,
help:
'only release the packages that opt-in for batch release option.');
argParser.addFlag(
_dryRunFlag,
help:
Expand All @@ -99,6 +102,7 @@ class PublishCommand extends PackageLoopingCommand {
static const String _pubFlagsOption = 'pub-publish-flags';
static const String _remoteOption = 'remote';
static const String _allChangedFlag = 'all-changed';
static const String _batchReleaseFlag = 'batch-release';
static const String _dryRunFlag = 'dry-run';
static const String _skipConfirmationFlag = 'skip-confirmation';
static const String _tagForAutoPublishFlag = 'tag-for-auto-publish';
Expand Down Expand Up @@ -182,6 +186,33 @@ class PublishCommand extends PackageLoopingCommand {
.toList();

for (final String pubspecPath in changedPubspecs) {
// Read the ci_config.yaml file

final String packageName = p.basename(p.dirname(pubspecPath));
bool isBatchReleasePackage;
try {
final File ciConfigFile = packagesDir.fileSystem
.file(pubspecPath)
.parent
.childFile('ci_config.yaml');
final YamlMap? ciConfig =
loadYaml(ciConfigFile.readAsStringSync()) as YamlMap?;
final dynamic batchValue = ciConfig?['release']?['batch'];
if (batchValue is! bool) {
printError(
'`release.batch` key is missing or not a boolean in ci_config.yaml for $packageName.');
continue;
}
isBatchReleasePackage = batchValue;
} catch (e) {
printError('Could not parse ci_config.yaml for $packageName: $e');
continue;
}
// Skip the package if batch release flag is not set to match the ci_config.yaml
if (getBoolArg(_batchReleaseFlag) != isBatchReleasePackage) {
continue;
}

// git outputs a relativa, Posix-style path.
final File pubspecFile = childFileWithSubcomponents(
packagesDir.fileSystem.directory((await gitDir).path),
Expand Down