-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[batch-release] Step2 : Publish packages from the release branch #10459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
102de85
bafe3ea
633d026
7187d66
8972d5a
0f8447b
9655b5a
d55dbd8
a00c2fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: Batch Release | ||
| on: | ||
| push: | ||
| branches: | ||
| - 'release-go-router' | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| jobs: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we were to reuse a common release sub workflow for both because we have to make sure the sub workflow works before using it for |
||
| release: | ||
| uses: ./.github/workflows/release.yml | ||
| with: | ||
| publish-args: '--all-changed --batch-release --base-sha=HEAD~ --skip-confirmation --remote=origin' | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| workflow-name: 'Batch Release ${{ github.ref_name }}' | ||
| branch-name: '${{ github.ref_name }}' | ||
| secrets: inherit | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: Main Release | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| release: | ||
| uses: ./.github/workflows/release.yml | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| with: | ||
| publish-args: '--all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin' | ||
| workflow-name: 'Main Release' | ||
| branch-name: 'main' | ||
| secrets: inherit | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import 'package:platform/platform.dart'; | |
| import 'package:pub_semver/pub_semver.dart'; | ||
| import 'package:yaml/yaml.dart'; | ||
|
|
||
| import 'common/ci_config.dart'; | ||
| import 'common/core.dart'; | ||
| import 'common/file_utils.dart'; | ||
| import 'common/output_utils.dart'; | ||
|
|
@@ -83,6 +84,10 @@ 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: | ||
|
|
@@ -109,6 +114,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'; | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| static const String _dryRunFlag = 'dry-run'; | ||
| static const String _skipConfirmationFlag = 'skip-confirmation'; | ||
| static const String _tagForAutoPublishFlag = 'tag-for-auto-publish'; | ||
|
|
@@ -196,6 +202,31 @@ class PublishCommand extends PackageLoopingCommand { | |
| .toList(); | ||
|
|
||
| for (final pubspecPath in changedPubspecs) { | ||
| // Read the ci_config.yaml file if it exists | ||
|
|
||
|
||
| final String packageName = p.basename(p.dirname(pubspecPath)); | ||
| bool isBatchReleasePackage; | ||
|
||
| try { | ||
| final File ciConfigFile = packagesDir.fileSystem | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .file(pubspecPath) | ||
| .parent | ||
| .childFile('ci_config.yaml'); | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!ciConfigFile.existsSync()) { | ||
| isBatchReleasePackage = false; | ||
| } else { | ||
| final CIConfig ciConfig = | ||
| CIConfig.parse(ciConfigFile.readAsStringSync()); | ||
| isBatchReleasePackage = ciConfig.isBatchRelease; | ||
| } | ||
| } catch (e) { | ||
| printError('Could not parse ci_config.yaml for $packageName: $e'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should throw tool exit in this case
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also should add a test for this |
||
| continue; | ||
| } | ||
| // Skip the package if batch release flag is not set to match the ci_config.yaml | ||
| if (getBoolArg(_batchReleaseFlag) != isBatchReleasePackage) { | ||
hannah-hyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| continue; | ||
| } | ||
|
|
||
| // git outputs a relativa, Posix-style path. | ||
| final File pubspecFile = childFileWithSubcomponents( | ||
| packagesDir.fileSystem.directory((await gitDir).path), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,7 @@ RepositoryPackage createFakePlugin( | |
| String? version = '0.0.1', | ||
| String flutterConstraint = _defaultFlutterConstraint, | ||
| String dartConstraint = _defaultDartConstraint, | ||
| bool? batchRelease, | ||
|
||
| }) { | ||
| final RepositoryPackage package = createFakePackage( | ||
| name, | ||
|
|
@@ -117,6 +118,9 @@ RepositoryPackage createFakePlugin( | |
| flutterConstraint: flutterConstraint, | ||
| dartConstraint: dartConstraint, | ||
| ); | ||
| if (batchRelease != null) { | ||
| createFakeCiConfig(batchRelease, package); | ||
| } | ||
|
|
||
| return package; | ||
| } | ||
|
|
@@ -287,6 +291,18 @@ $pluginSection | |
| package.pubspecFile.writeAsStringSync(yaml); | ||
| } | ||
|
|
||
| /// Creates a `ci_config.yaml` file for [package]. | ||
| void createFakeCiConfig(bool batchRelease, RepositoryPackage package) { | ||
| final yaml = | ||
| ''' | ||
| release: | ||
| batch: $batchRelease | ||
| '''; | ||
|
|
||
| package.ciConfigFile.createSync(); | ||
| package.ciConfigFile.writeAsStringSync(yaml); | ||
| } | ||
|
|
||
| String _pluginPlatformSection( | ||
| String platform, | ||
| PlatformDetails support, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.