Supports all Melos filtering flags.
Publish any unpublished packages or package versions in your repository to
pub.dev. dry-run is enabled by default.
melos publishFlags whether to publish the packages as a dry run (validate but do not
publish). Defaults to true.
# Publish packages with dry run
melos publish --dry-run
# Publish packages without dry run
melos publish --no-dry-runUse --no-dry-run to disable.
The URL of the package server to publish to. When set, --server <url> is
forwarded to dart pub publish, overriding the per-package publish_to field
in pubspec.yaml.
melos publish --no-dry-run --server https://pub.flutter-io.cnThis can also be set workspace-wide in melos.yaml via the pubServer option
under command/publish, so you don't have to pass it on every invocation:
# melos.yaml
command:
publish:
pubServer: https://pub.flutter-io.cnThe CLI flag takes precedence over the pubServer config value when both are
provided.
Add any missing git tags for release. Tags are only created if --no-dry-run is also set.
melos publish --no-dry-run --git-tag-versionNote that tags are automatically created as part of melos version (unless
--no-git-tag-version is specified when running the version command) so this is
usually not required on melos publish unless you're doing a manual version and
publish of packages.
Melos supports various command lifecycle hooks
that can be defined in your root pubspec.yaml.
For example, if you need to run something such as a build runner automatically
before melos publish is run and then remove the generated files after
publishing is done, you can add pre and post hook scripts to your
root pubspec.yaml file:
# root pubspec.yaml
# ...
melos:
command:
publish:
hooks:
pre: dart pub run build_runner build
post: dart pub run build_runner clean
# ...The pre-hook will run before melos publish and the post-hook will run after
melos publish is done. It only runs once, even if multiple packages are
published and it also runs when you are doing a dry-run publish.
You can detect whether it is a dry-run by checking the MELOS_PUBLISH_DRY_RUN
environment variable.

